void unlock()
 {
     boost::mutex::scoped_lock lk(state_change);
     state.exclusive=false;
     state.exclusive_waiting_blocked=false;
     release_waiters();
 }
 void unlock_upgrade_and_lock_shared()
 {
     boost::mutex::scoped_lock lk(state_change);
     state.upgrade=false;
     state.exclusive_waiting_blocked=false;
     release_waiters();
 }
Exemplo n.º 3
0
 void unlock()
 {
     typename mutex_type::scoped_lock lk(state_change);
     state.exclusive = false;
     state.exclusive_waiting_blocked = false;
     release_waiters();
 }
 void unlock_and_lock_shared()
 {
     boost::mutex::scoped_lock lk(state_change);
     state.exclusive=false;
     ++state.shared_count;
     state.exclusive_waiting_blocked=false;
     release_waiters();
 }
Exemplo n.º 5
0
 void unlock_and_lock_upgrade()
 {
     typename mutex_type::scoped_lock lk(state_change);
     state.exclusive = false;
     state.upgrade = true;
     ++state.shared_count;
     state.exclusive_waiting_blocked = false;
     release_waiters();
 }
        void unlock_upgrade()
        {
            boost::mutex::scoped_lock lk(state_change);
            state.upgrade=false;
            bool const last_reader=!--state.shared_count;

            if(last_reader)
            {
                state.exclusive_waiting_blocked=false;
                release_waiters();
            }
        }
        void unlock_shared()
        {
            boost::mutex::scoped_lock lk(state_change);
            bool const last_reader=!--state.shared_count;

            if(last_reader)
            {
                if(state.upgrade)
                {
                    state.upgrade=false;
                    state.exclusive=true;
                    upgrade_cond.notify_one();
                }
                else
                {
                    state.exclusive_waiting_blocked=false;
                }
                release_waiters();
            }
        }
Exemplo n.º 8
0
        bool timed_lock(system_time const& timeout)
        {
            boost::this_thread::disable_interruption do_not_disturb;
            boost::mutex::scoped_lock lk(state_change);

            while(state.shared_count || state.exclusive)
            {
                state.exclusive_waiting_blocked=true;
                if(!exclusive_cond.timed_wait(lk,timeout))
                {
                    if(state.shared_count || state.exclusive)
                    {
                        state.exclusive_waiting_blocked=false;
                        release_waiters();
                        return false;
                    }
                    break;
                }
            }
            state.exclusive=true;
            return true;
        }
Exemplo n.º 9
0
            void unlock_shared()
            {
                typename mutex_type::scoped_lock lk(state_change);

                bool const last_reader = !--state.shared_count;

                if (last_reader)
                {
                    if (state.upgrade)
                    {
                        state.upgrade = false;
                        state.exclusive = true;
                        upgrade_cond.signal(1);
                    }

                    else
                    {
                        state.exclusive_waiting_blocked = false;
                    }

                    release_waiters();
                }
            }