views:

88

answers:

2

boost/thread/pthread/shared_mutex.hpp contains this code:

...
#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;
    }
    ...
};

but boost/thread/detail/thread_interruption.hpp does not contain implementation of disable_interruption, only the prototype.

in boost_1_42_0/libs/thread/src/pthread we don't have the implementation too

how does it work!???

+1  A: 

grep finds it in boost_1_42_0/libs/thread/src/pthread/thread.cpp:

    disable_interruption::disable_interruption():
        interruption_was_enabled(interruption_enabled())
    {
        if(interruption_was_enabled)
        {
            detail::get_current_thread_data()->interrupt_enabled=false;
        }
    }

Destructor and methods are all there too.

Potatoswatter
thank you very much!!! I don't know how can I miss it...
Evgenii
A: 

There are 2 implementations of disable_interruption.

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

You link against the appropriate one depending on your platform

Glen