Inherited from execution_context.
Notify the
execution_context
of a fork-related event.
void notify_fork( fork_event event);
This function is used to inform the execution_context
that the process is about to fork, or has just forked. This allows the
execution_context
,
and the services it contains, to perform any necessary housekeeping to
ensure correct operation following a fork.
This function must not be called while any other execution_context
function, or any function associated with the execution_context's derived
class, is being called in another thread. It is, however, safe to call
this function from within a completion handler, provided no other thread
is accessing the execution_context
or its derived class.
A fork-related event.
Thrown on failure. If the notification fails the execution_context
object should no longer be used and should be destroyed.
The following code illustrates how to incorporate the notify_fork()
function:
my_execution_context.notify_fork(execution_context::fork_prepare); if (fork() == 0) { // This is the child process. my_execution_context.notify_fork(execution_context::fork_child); } else { // This is the parent process. my_execution_context.notify_fork(execution_context::fork_parent); }
For each service object svc
in the execution_context
set, performs svc->notify_fork();
. When processing the
fork_prepare event, services are visited in reverse order of the beginning
of service object lifetime. Otherwise, services are visited in order of
the beginning of service object lifetime.