Organizational Research By

Surprising Reserch Topic

shared connection over multiply threads


shared connection over multiply threads  using -'c++,mongodb'

Is it possible to create pointer of DBClientConnection and use it in multiply threads?

connection = new DBClientConnection();
connection->connect("localhost");


Then use connection in thread.

Is it safe to access to connection simultaneously?
    

asked Oct 6, 2015 by vijaygupta1980
0 votes
3 views



Related Hot Questions

1 Answer

0 votes

No. DBClientConnection is not thread safe and should not be shared with more than one thread. You might also want to check ScopedDbConnection, which is backed by a connection pool and closes the socket for you upon destruction.

answered Oct 6, 2015 by param.oncemore

...