8 #ifndef BOOSTER_UTIL_THREAD_H 9 #define BOOSTER_UTIL_THREAD_H 11 #include <booster/hold_ptr.h> 12 #include <booster/noncopyable.h> 13 #include <booster/refcounted.h> 14 #include <booster/intrusive_ptr.h> 15 #include <booster/function.h> 16 #include <booster/config.h> 20 #include <condition_variable> 26 using std::recursive_mutex;
27 using std::condition_variable;
28 using std::unique_lock;
46 void lock() { unique_lock(); }
81 void lock() { unique_lock(); }
107 key(
void (*d)(
void *)) :
117 void destroy(
void *p)
121 virtual tls_object *get_object() = 0;
123 void (*dtor_)(
void *);
136 the_key->destroy(obj);
143 inline void key::set(
void *p)
145 get_object()->obj = p;
147 inline void *key::get()
149 return get_object()->obj;
200 return static_cast<T*
>(key_->get());
226 key_->set(static_cast<void *>(new_val));
240 static void destructor(
void *ptr)
242 delete static_cast<T*
>(ptr);
253 template<
typename Mutex>
275 class BOOSTER_API fork_shared_mutex :
public noncopyable {
286 ~fork_shared_mutex();
291 bool try_lock() {
return try_unique_lock(); }
295 bool try_unique_lock();
299 bool try_shared_lock();
304 void lock() {
return unique_lock(); }
T * operator->() const
Definition: thread.h:205
void lock()
Definition: thread.h:81
thread_specific_ptr()
Definition: thread.h:185
Thread specific pointer.
Definition: thread.h:180
Recursuve Shared mutex or a.k.a. Read-Write Lock that can be recursively locked by readers...
Definition: thread.h:37
~thread_specific_ptr()
Definition: thread.h:192
void lock()
Definition: thread.h:46
This class is used as base class for reference counted objects that use intrusive_ptr. Deriving from this class allows simple way to manage reference counting for single object.
Definition: refcounted.h:25
shared_lock(Mutex &m)
Acquire the lock.
Definition: thread.h:257
T & operator*() const
Definition: thread.h:212
~shared_lock()
Release the lock.
Definition: thread.h:262
Shared mutex or a.k.a. Read-Write Lock.
Definition: thread.h:74
a Shared lock guard.
Definition: thread.h:254
intrusive_ptr is the class taken as-is from boost.
Definition: intrusive_ptr.h:42
void reset(T *new_val=0)
Definition: thread.h:221
Mutex * mutex() const
Get the reference to the mutex object.
Definition: thread.h:267
Booster library namespace. The library that implements Boost Like API in ABI backward compatible way...
Definition: application.h:23
This class makes impossible to copy any class derived from this one.
Definition: noncopyable.h:15
T * release()
Definition: thread.h:233