ScopedDBConnection’s constructor gets a connection from pool(if can’t it will create a new one) and save it as a private member variable.Its get method returns a pointer of DBClientBase,I thinks client code don’t need to delete this pointer because the done method will return it back to the pool. Here is my code,am I right.
ScopedDbConnection con(...);
DBClientBase* session = con.get();
//do something using session
...
//
con.done();// ignore session because done will return it back to connection pool
You can find a number of good ScopedDbConnection examples in the MongoDB github. Here’s a file that shows some basic usage of that class:
https://github.com/mongodb/mongo/blob/master/src/mongo/client/model.cpp
Check out lines 24-46 (Model::load).