示例#1
0
        // Execute the wrapped action. This locks the mutex ensuring a thread
        // safe action invocation.
        threads::thread_state_enum thread_function(
            threads::thread_state_ex_enum state,
            threads::thread_function_type f)
        {
            threads::thread_state_enum result = threads::unknown;

            // now lock the mutex and execute the action
            std::unique_lock<mutex_type> l(mtx_);

            // We can safely ignore this lock while checking as it is
            // guaranteed to be unlocked before the thread is suspended.
            //
            // If this lock is not ignored it will cause false positives as the
            // check for held locks is performed before this lock is unlocked.
            util::ignore_while_checking<
                    std::unique_lock<mutex_type>
                > ignore_lock(&l);

            {
                // register our yield decorator
                decorate_wrapper yield_decorator(
                    util::bind(&locking_hook::yield_function, this,
                        util::placeholders::_1));

                result = f(state);

                (void)yield_decorator;       // silence gcc warnings
            }

            return result;
        }
示例#2
0
 ignore_while_checking(boost::upgrade_lock<Mutex> const* lock)
   : mtx_(lock->mutex())
 {
     ignore_lock(mtx_);
 }
示例#3
0
 ignore_while_checking(Lock const* lock)
   : mtx_(lock->mutex())
 {
     ignore_lock(mtx_);
 }
示例#4
0
 ignore_while_checking(
         boost::detail::try_lock_wrapper<Mutex> const* lock)
   : mtx_(lock->mutex())
 {
     ignore_lock(mtx_);
 }