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 extern "C" void *booster_thread_func(
void *);
30 thread(
function<
void()>
const &cb);
46 static unsigned hardware_concurrency();
48 friend void *booster_thread_func(
void *);
193 template<
typename Mutex>
237 key(
void (*d)(
void *)) :
247 void destroy(
void *p)
251 virtual tls_object *get_object() = 0;
253 void (*dtor_)(
void *);
266 the_key->destroy(obj);
273 inline void key::set(
void *p)
275 get_object()->obj = p;
277 inline void *key::get()
279 return get_object()->obj;
330 return static_cast<T*
>(key_->get());
356 key_->set(static_cast<void *>(new_val));
370 static void destructor(
void *ptr)
372 delete static_cast<T*
>(ptr);
383 template<
typename Mutex>
410 template<
typename Mutex>
432 class BOOSTER_API fork_shared_mutex :
public noncopyable {
443 ~fork_shared_mutex();
448 bool try_lock() {
return try_unique_lock(); }
452 bool try_unique_lock();
456 bool try_shared_lock();
T * operator->() const
Definition: thread.h:335
Mutex object.
Definition: thread.h:59
void lock()
Definition: thread.h:173
thread_specific_ptr()
Definition: thread.h:315
Recursive mutex object.
Definition: thread.h:106
Thread specific pointer.
Definition: thread.h:310
Recursuve Shared mutex or a.k.a. Read-Write Lock that can be recursively locked by readers...
Definition: thread.h:129
~thread_specific_ptr()
Definition: thread.h:322
unique_lock(Mutex &m)
Acquire the lock.
Definition: thread.h:387
a Unique lock guard.
Definition: thread.h:194
void lock()
Definition: thread.h:138
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
Mutex * mutex() const
Get the reference to the mutex object.
Definition: thread.h:397
shared_lock(Mutex &m)
Acquire the lock.
Definition: thread.h:414
T & operator*() const
Definition: thread.h:342
~shared_lock()
Release the lock.
Definition: thread.h:419
~unique_lock()
Release the lock.
Definition: thread.h:392
Shared mutex or a.k.a. Read-Write Lock.
Definition: thread.h:166
a Shared lock guard.
Definition: thread.h:411
This is conditional variable object.
Definition: thread.h:201
intrusive_ptr is the class taken as-is from boost.
Definition: intrusive_ptr.h:42
the class that allows to start an execution thread
Definition: thread.h:25
void reset(T *new_val=0)
Definition: thread.h:351
Mutex * mutex() const
Get the reference to the mutex object.
Definition: thread.h:424
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:363