bool try_lock_until(util::steady_time_point const& abs_time, char const* description, error_code& ec = throws) { HPX_ASSERT(threads::get_self_ptr() != 0); HPX_ITT_SYNC_PREPARE(this); mutex_type::scoped_lock l(mtx_); threads::thread_id_repr_type self_id = threads::get_self_id().get(); if (owner_id_ != threads::invalid_thread_id_repr) { threads::thread_state_ex_enum const reason = cond_.wait_until(l, abs_time, ec); if (ec) { HPX_ITT_SYNC_CANCEL(this); return false; } if (reason == threads::wait_signaled) //-V110 { HPX_ITT_SYNC_CANCEL(this); return false; } } util::register_lock(this); HPX_ITT_SYNC_ACQUIRED(this); owner_id_ = self_id; return true; }
void lock(char const* description, error_code& ec = throws) { HPX_ASSERT(threads::get_self_ptr() != 0); HPX_ITT_SYNC_PREPARE(this); mutex_type::scoped_lock l(mtx_); threads::thread_id_repr_type self_id = threads::get_self_id().get(); if(owner_id_ == self_id) { HPX_ITT_SYNC_CANCEL(this); HPX_THROWS_IF(ec, deadlock, "mutex::unlock", "The calling thread already owns the mutex"); return; } if (owner_id_ != threads::invalid_thread_id_repr) { cond_.wait(l, ec); if (ec) { HPX_ITT_SYNC_CANCEL(this); return; } } util::register_lock(this); HPX_ITT_SYNC_ACQUIRED(this); owner_id_ = self_id; }
bool mutex::timed_lock(::boost::system_time const& wait_until) { HPX_ITT_SYNC_PREPARE(this); if (try_lock_internal()) { HPX_ITT_SYNC_ACQUIRED(this); util::register_lock(this); return true; } boost::uint32_t old_count = active_count_.load(boost::memory_order_acquire); mark_waiting_and_try_lock(old_count); if (old_count & lock_flag_value) { // wait for lock to get available bool lock_acquired = false; do { if (wait_for_single_object(wait_until)) { // if this timed out, just return false --active_count_; HPX_ITT_SYNC_CANCEL(this); return false; } clear_waiting_and_try_lock(old_count); lock_acquired = !(old_count & lock_flag_value); } while (!lock_acquired); } HPX_ITT_SYNC_ACQUIRED(this); util::register_lock(this); return true; }
bool try_lock() { HPX_ITT_SYNC_PREPARE(this); if (m.try_lock()) { HPX_ITT_SYNC_ACQUIRED(this); util::register_lock(this); return true; } HPX_ITT_SYNC_CANCEL(this); return false; }
bool try_lock() { HPX_ITT_SYNC_PREPARE(this); if (acquire_lock()) { HPX_ITT_SYNC_ACQUIRED(this); return true; } HPX_ITT_SYNC_CANCEL(this); return false; }
bool try_lock() { HPX_ITT_SYNC_PREPARE(this); bool r = acquire_lock(); //-V707 if (r) { HPX_ITT_SYNC_ACQUIRED(this); util::register_lock(this); return true; } HPX_ITT_SYNC_CANCEL(this); return false; }
bool try_lock(char const* description, error_code& ec = throws) { HPX_ASSERT(threads::get_self_ptr() != 0); HPX_ITT_SYNC_PREPARE(this); mutex_type::scoped_lock l(mtx_); threads::thread_id_repr_type self_id = threads::get_self_id().get(); if (owner_id_ != threads::invalid_thread_id_repr) { HPX_ITT_SYNC_CANCEL(this); return false; } util::register_lock(this); HPX_ITT_SYNC_ACQUIRED(this); owner_id_ = self_id; return true; }
bool try_lock() { HPX_ITT_SYNC_PREPARE(this); #if !defined( BOOST_SP_HAS_SYNC ) boost::uint64_t r = BOOST_INTERLOCKED_EXCHANGE(&v_, 1); BOOST_COMPILER_FENCE #else boost::uint64_t r = __sync_lock_test_and_set(&v_, 1); #endif if (r == 0) { HPX_ITT_SYNC_ACQUIRED(this); util::register_lock(this); return true; } HPX_ITT_SYNC_CANCEL(this); return false; }