![](/img/trans.png)
[英]How to detect if handler is an ASIO strand wrap and call it through the 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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.