2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
7 * @file AthContainers/tools.threading.icc
8 * @author scott snyder <snyder@bnl.gov>
10 * @brief Threading definitions.
14 namespace AthContainers_detail {
17 #ifndef ATHCONTAINERS_NO_THREADS
21 * @brief An acquire/release fence.
26 std::atomic_thread_fence (std::memory_order_acq_rel);
31 * @brief A sequentially-consistent fence.
36 std::atomic_thread_fence (std::memory_order_seq_cst);
44 * @brief Take out a shared lock on @c obj and remember it.
45 * @param obj The lockable object.
47 template <typename LOCKABLE>
49 strict_shared_lock<LOCKABLE>::strict_shared_lock (lockable_type& obj)
52 obj.lock_shared(); // locks on construction
57 * @brief Take out a shared lock on @c obj and remember it.
58 * @param obj The lockable object.
60 template <typename LOCKABLE>
62 strict_shared_lock<LOCKABLE>::strict_shared_lock (const lockable_type& obj)
63 : m_obj(const_cast<lockable_type&>(obj))
65 obj.lock_shared(); // locks on construction
70 * @brief Release the held lock.
72 template <typename LOCKABLE>
74 strict_shared_lock<LOCKABLE>::~strict_shared_lock()
76 m_obj.unlock_shared(); // unlocks on destruction
81 * @brief Take out an upgrade lock on @c obj and remember it.
82 * @param obj The lockable object.
84 template <typename LOCKABLE>
86 upgrading_lock<LOCKABLE>::upgrading_lock (lockable_type& obj)
95 * @brief Release the held lock.
97 template <typename LOCKABLE>
99 upgrading_lock<LOCKABLE>::~upgrading_lock()
104 m_obj.unlock_upgrade();
109 * @brief Convert the lock from upgrade to exclusive.
111 template <typename LOCKABLE>
113 void upgrading_lock<LOCKABLE>::upgrade()
116 m_obj.unlock_upgrade_and_lock();
123 } // namespace AthContainers_detail