UCommon
thread.h File Reference

Thread classes and sychronization objects. More...

#include <ucommon/cpr.h>
#include <ucommon/timers.h>
#include <ucommon/memory.h>
#include <ucommon/condition.h>
Include dependency graph for thread.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  ucommon::AutoProtect
 Guard class to apply scope based mutex locking to objects. More...
 
class  ucommon::DetachedThread
 A detached thread object that is stand-alone. More...
 
class  ucommon::JoinableThread
 A child thread object that may be joined by parent. More...
 
class  ucommon::Mutex
 Generic non-recursive exclusive lock class. More...
 
class  ucommon::RecursiveMutex
 Portable recursive exclusive lock. More...
 
class  ucommon::ReusableAllocator
 Class for resource bound memory pools between threads. More...
 
class  ucommon::RWLock
 A generic and portable implementation of Read/Write locking. More...
 
class  ucommon::RWLock::reader
 Apply automatic scope based access locking to objects. More...
 
class  ucommon::RWLock::writer
 Apply automatic scope based exclusive locking to objects. More...
 
class  ucommon::Thread
 An abstract class for defining classes that operate as a thread. More...
 
class  ucommon::TimedEvent
 Event notification to manage scheduled realtime threads. More...
 

Namespaces

namespace  ucommon
 Common namespace for all ucommon objects.
 

Macros

#define __AUTOLOCK(x)   autolock __autolock__(x)
 
#define __AUTOPROTECT(x)   AutoProtect __autolock__(x)
 
#define __SYNC(x)   for(bool _sync_flag_ = Mutex::protect(x); _sync_flag_; _sync_flag_ = !Mutex::release(x))
 

Typedefs

typedef Mutex ucommon::mutex_t
 Convenience type for using exclusive mutex locks.
 
typedef RecursiveMutex ucommon::rexlock_t
 Convenience type for using recursive exclusive locks.
 
typedef RWLock ucommon::rwlock_t
 Convenience type for using read/write locks.
 
typedef TimedEvent ucommon::timedevent_t
 Convenience type for using timed events.
 

Detailed Description

Thread classes and sychronization objects.

The theory behind ucommon thread classes is that they would be used to create derived classes where thread-specific data can be stored as member data of the derived class. The run method is called when the context is executed. Since we use a pthread foundation, we support both detached threads and joinable threads. Objects based on detached threads should be created with new, and will automatically delete when the thread context exits. Joinable threads will be joined with deleted.

Definition in file thread.h.

Macro Definition Documentation

◆ __AUTOLOCK

#define __AUTOLOCK ( x)    autolock __autolock__(x)

Definition at line 952 of file thread.h.

◆ __AUTOPROTECT

#define __AUTOPROTECT ( x)    AutoProtect __autolock__(x)

Definition at line 953 of file thread.h.

◆ __SYNC

#define __SYNC ( x)    for(bool _sync_flag_ = Mutex::protect(x); _sync_flag_; _sync_flag_ = !Mutex::release(x))

Definition at line 954 of file thread.h.