3 #ifndef CDSLIB_SYNC_INJECTED_MONITOR_H
4 #define CDSLIB_SYNC_INJECTED_MONITOR_H
6 namespace cds { namespace sync {
8 /// @ref cds_sync_monitor "Monitor" that injects the lock into each node
10 This monitor injects the lock object of type \p Lock into each node.
11 The monitor is designed for user-space locking primitives like \ref sync::spin_lock "spin-lock".
14 - Lock - lock type like \p std::mutex or \p cds::sync::spin
18 template <typename Lock>
19 class injected_monitor
22 typedef Lock lock_type; ///< Lock type
24 /// Monitor injection into \p T
26 struct wrapper : public T
29 mutable lock_type m_Lock; ///< Node-level lock
31 /// Makes exclusive access to the object
37 /// Unlocks the object
44 /// Makes exclusive access to node \p p of type \p T
46 \p p must have method \p lock()
49 void lock( T const& p ) const
54 /// Unlocks the node \p p of type \p T
56 \p p must have method \p unlock()
59 void unlock( T const& p ) const
68 T const& m_Locked; ///< Our locked node
71 /// Makes exclusive access to object \p p of type T
72 scoped_lock( injected_monitor const&, T const& p )
78 /// Unlocks the object
85 }} // namespace cds::sync
87 #endif // #ifndef CDSLIB_SYNC_INJECTED_MONITOR_H