如何在运行时检查代码是否由给定的asio::strand实例保护
How to runtime-check if code is guarded by given asio::strand instance
我想在代码中添加一个运行时断言,用于检查代码是否由给定的链保护。
下面是一个伪示例:
...
asio::io_service my_io_service;
asio::strand my_strand(my_io_service);
...
void my_async_callback(void) {
// ASSERT that check that my_strand is guarding then code
ASSERT(?? my_strand ??)
}
...
// With this call my_async_callback is guarded by strand
my_strand.post(&my_async_callback);
...
// With this call my_async_callback is NOT guarded by strand
io_service.post(&my_async_callback);
我想你可能正在寻找
assert(my_strand.running_in_this_thread());
请参阅文档页面
相关文章:
- 理解boost::asio-async_read在无需读取内容时的行为
- 提升 ASIO 无法识别计时器对象
- C++Boost Asio Pool线程,带有lambda函数和传递引用变量
- boost::asio::steady_timer()与sleep()我应该使用哪一个
- boost::asio如何生成多个协同程序,然后加入它们
- 缓慢提升ASIO
- 从 Boost ASIO 获取 epoll 描述符 io_service对象
- 如何在 Boost.Asio 中使用 Zero-copy sendmsg/receive
- 使用boost :: asio :: strand以这种方式安全吗?
- asio::strand 上的任务在单个线程上运行
- boost::asio::strand post方法性能
- 提升在多个线程上运行的asio-strand和io_service
- boost::asio:"strand"类型的同步原语有什么名称吗?
- asio/strand:为什么计时器的行为不同
- strand在boost asio中的优势是什么?
- 正确使用asio::io_service::strand
- boost::asio::strand wrap导致shared_ptr从shared_from_this变为NULL
- 如何在运行时检查代码是否由给定的asio::strand实例保护
- Boost::asio::strand::dispatch(句柄)或直接调用句柄
- 可以提高.Asio strand.dispatch()块