io_service::notify_fork函数详解
来源:互联网 发布:ubuntu恢复系统 编辑:程序博客网 时间:2024/05/21 20:26
io_service::notify_fork
Notify the io_service
of a fork-related event.
void notify_fork( boost::asio::io_service::fork_event event);
This function is used to inform the io_service
that the process is about to fork, or has just forked. This allows the io_service
, 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 io_service
function, or any function on an I/O object associated with the io_service
, 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 theio_service
.
Parameters
- event
A fork-related event.
Exceptions
- boost::system::system_error
Thrown on failure. If the notification fails the
io_service
object should no longer be used and should be destroyed.
Example
The following code illustrates how to incorporate the notify_fork()
function:
my_io_service.notify_fork(boost::asio::io_service::fork_prepare);if (fork() == 0){ // This is the child process. my_io_service.notify_fork(boost::asio::io_service::fork_child);}else{ // This is the parent process. my_io_service.notify_fork(boost::asio::io_service::fork_parent);}
Remarks
For each service object svc
in the io_service
set, performs svc->fork_service();
. 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.
- io_service::notify_fork函数详解
- io_service
- io_service
- boost库asio详解2——io_service::run函数无任务时退出的问题
- 【Boost】boost库asio详解2——io_service::run函数无任务时退出的问题
- 【Boost】boost库asio详解2——io_service::run函数无任务时退出的问题
- 【Boost】boost库asio详解1——io_service::run函数无任务时退出的问题
- boost asio 中io_service stop函数注意
- boost::asio-start(1): The basics of io_service详解
- boost::asio::io_service的stop()和reset()和stopped()函数
- boost io_service
- io_service用法
- 【Boost】boost库asio详解1——strand与io_service区别
- 【Boost】boost库asio详解3——io_service作为work pool
- 【Boost】boost库asio详解3——io_service作为work pool
- boost库asio详解1——strand与io_service区别
- boost库asio详解3——io_service作为work pool
- 【Boost】boost库asio详解3——io_service作为work pool
- 基于JQuery网页漂浮广告窗口Js详解
- 2016.4.6
- 将amr文件转成mp3
- android系统自带的振动器以及倒计时器
- 有没在php代码中设置session的timeout代码?
- io_service::notify_fork函数详解
- SQL2005 触发器简介
- php 5.6.19连接数据库
- 11g两节点RAC添加第三个节点
- json和jsonp
- raspberry noobs 系统分区解析与镜像备份
- 包含min函数的栈
- 利用线程运行栈StackTraceElement设计Android日志模块
- LeetCode 226 -Invert Binary Tree ( JAVA )