0

All.

I'm novice in boost synchronization, so will be grateful for some critic of code below.

It is ok to use it in multi-threaded environment ?

Few threads just wait until My_boost_event::is_siagnaled() return true . "Controller" thread just initiate settings of event to "signaled" state.

Thank you.

class My_boost_event
{
private:
    boost::mutex mutex_;
    bool   m_signaled;

public:

    My_boost_event(bool signaled) : m_signaled(signaled)
    {
    }

    void set()
    {
        boost::mutex::scoped_lock lock(mutex_);
        m_signaled = true ;
    }

    void reset()
    {
        boost::mutex::scoped_lock lock(mutex_);
        m_signaled = false;
    }


    bool is_signaled()
    {
        boost::mutex::scoped_lock lock(mutex_);
        return m_signaled;
    }
};
user1503944
  • 387
  • 2
  • 16
  • Why don't you test it yourself in the debugger with some simple use/test cases? – ManuelH Jul 31 '15 at 08:01
  • Already done. But it's also works, in most cases, if I'm even change global variable without any synchronization :) I just need to know if I'm do it properly. – user1503944 Jul 31 '15 at 08:10

0 Answers0