首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >boost::this_thread::disable_interruption用法混乱

boost::this_thread::disable_interruption用法混乱
EN

Stack Overflow用户
提问于 2010-05-06 19:19:45
回答 2查看 741关注 0票数 1

boost/thread/pthread/shared_mutex.hpp包含以下代码:

代码语言:javascript
复制
...
#include <boost/thread/detail/thread_interruption.hpp>
...

class shared_mutex
{
    ...
    void lock_shared()
    {
        boost::this_thread::disable_interruption do_not_disturb;
        boost::mutex::scoped_lock lk(state_change);

        while(state.exclusive || state.exclusive_waiting_blocked)
        {
            shared_cond.wait(lk);
        }
        ++state.shared_count;
    }
    ...
};

但是boost/thread/detail/ThreadInterruption.hpp不包含disable_interruption的实现,只包含原型。

在boost_1_42_0/libs/thread/src/pthread中,我们也没有实现

它是如何工作的!?

EN

回答 2

Stack Overflow用户

发布于 2010-05-06 20:04:00

grepboost_1_42_0/libs/thread/src/pthread/thread.cpp中找到它

代码语言:javascript
复制
    disable_interruption::disable_interruption():
        interruption_was_enabled(interruption_enabled())
    {
        if(interruption_was_enabled)
        {
            detail::get_current_thread_data()->interrupt_enabled=false;
        }
    }

析构函数和方法也都在那里。

票数 1
EN

Stack Overflow用户

发布于 2010-05-06 20:08:46

disable_interruption有两个实现。

  1. boost_1_42_0/libs/thread/src/pthread/thread.cpp
  2. boost_1_42_0/libs/thread/src/win32/thread.cpp

根据您的平台,您可以链接到适当的链接

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2780631

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档