Skip to content

Commit 4c858c8

Browse files
authored
[C++] Document connection pool vs process fork order (#100)
* add fork safety
1 parent 993c09b commit 4c858c8

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

source/connect/connection-pools.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,21 @@ rather than "stopping the world", it's highly recommended to use a
2929
application has access to multiple threads, even if your application only
3030
uses one thread.
3131

32-
Connection Pools and Thread Safety
33-
----------------------------------
32+
Using Threads with Connection Pools
33+
-----------------------------------
3434

3535
A ``mongocxx::pool`` can be shared across multiple threads and used to create
3636
clients. However, each ``mongocxx::client`` can only be used in a single
3737
thread. See the :ref:`thread safety documentation <cpp-thread-safety>` for
3838
details on how to use a ``mongocxx::client`` in a thread-safe manner.
3939

40+
Using Forks with Connection Pools
41+
----------------------------------
42+
43+
A ``mongocxx::pool`` **cannot** be shared between a parent and a fork.
44+
You must create your connection pool after forking. See the :ref:`fork safety
45+
documentation <cpp-fork-safety>` documentation.
46+
4047
Configuring a Connection Pool
4148
-----------------------------
4249

source/thread-safety.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ In most programs, clients will be long lived for convenience and performance. In
117117
there's quite a bit of overhead because we're doing so little work with each
118118
client, but typically this is the best solution.
119119

120+
.. _cpp-fork-safety:
121+
120122
Fork Safety
121123
-----------
122124

0 commit comments

Comments
 (0)