File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -515,6 +515,6 @@ namespace mongo {
515515 pool.clear ();
516516 }
517517
518- AtomicUInt AScopedConnection::_numConnections;
518+ AtomicInt32 AScopedConnection::_numConnections;
519519
520520} // namespace mongo
Original file line number Diff line number Diff line change 3333
3434#include " mongo/client/dbclientinterface.h"
3535#include " mongo/client/export_macros.h"
36+ #include " mongo/platform/atomic_word.h"
3637#include " mongo/platform/cstdint.h"
3738#include " mongo/util/background.h"
3839
@@ -268,8 +269,8 @@ namespace mongo {
268269
269270 class MONGO_CLIENT_API AScopedConnection : boost::noncopyable {
270271 public:
271- AScopedConnection () { _numConnections++ ; }
272- virtual ~AScopedConnection () { _numConnections-- ; }
272+ AScopedConnection () { _numConnections. fetchAndAdd ( 1 ) ; }
273+ virtual ~AScopedConnection () { _numConnections. fetchAndAdd (- 1 ) ; }
273274
274275 virtual DBClientBase* get () = 0;
275276 virtual void done () = 0;
@@ -283,10 +284,10 @@ namespace mongo {
283284 /* *
284285 * @return total number of current instances of AScopedConnection
285286 */
286- static int getNumConnections () { return _numConnections; }
287+ static int getNumConnections () { return _numConnections. load () ; }
287288
288289 private:
289- static AtomicUInt _numConnections;
290+ static AtomicInt32 _numConnections;
290291 };
291292
292293 /* * Use to get a connection from the pool. On exceptions things
You can’t perform that action at this time.
0 commit comments