【发布时间】:2020-06-01 08:57:32
【问题描述】:
我有一份asio::io_service::strand 的副本。
复制的链及其来源是不同的执行者吗?换句话说,传递给复制链的函数和传递给源链的另一个函数是否有可能由两个不同的线程同时执行?
或者这两个链在逻辑上都是“一个链”,这意味着传递给它们的任何工作都不会与传递给它们的其他工作一起执行?
查看示例
asio::io_service ioService;
asio::io_service::strand strandFromIoService{ioService};
asio::io_service::strand strandFromStrand{strandFromIoService};
strandFromIoService.post(boost::bind(&firstFunction));
strandFromStrand.post(boost::bind(&secondFunction));
// then use a pool of threads to service io_service ...
// can firstFunction and secondFunction be executed in one time?
【问题讨论】:
标签: c++ multithreading concurrency boost-asio