繁体   English   中英

如何运行时检查代码是否由给定的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());

请参阅文档页面

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM