簡體   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