TinyThread++ 1.1
Classes | Namespaces | Defines | Typedefs | Functions
tinythread.h File Reference
#include <pthread.h>
#include <signal.h>
#include <sched.h>
#include <unistd.h>
#include <ostream>

Go to the source code of this file.

Classes

class  mutex
 Mutex class. More...
class  recursive_mutex
 Recursive mutex class. More...
class  lock_guard< T >
 Lock guard class. More...
class  condition_variable
 Condition variable class. More...
class  thread
 Thread class. More...
class  thread::id
 Thread ID. More...
class  ratio< N, D >
 Minimal implementation of the ratio class. More...
class  duration< _Rep, _Period >
 Duration template class. More...

Namespaces

namespace  tthread
 

Main name space for TinyThread++.


namespace  tthread::chrono
 

Minimal implementation of the chrono namespace.


namespace  tthread::this_thread
 

The namespace this_thread provides methods for dealing with the calling thread.


Defines

#define TINYTHREAD_VERSION_MAJOR   1
 TinyThread++ version (major number).
#define TINYTHREAD_VERSION_MINOR   1
 TinyThread++ version (minor number).
#define TINYTHREAD_VERSION   (TINYTHREAD_VERSION_MAJOR * 100 + TINYTHREAD_VERSION_MINOR)
 TinyThread++ version (full version).
#define thread_local
 Thread local storage keyword.

Typedefs

typedef duration< __intmax_t,
ratio< 1, 1000000000 > > 
nanoseconds
 Duration with the unit nanoseconds.
typedef duration< __intmax_t,
ratio< 1, 1000000 > > 
microseconds
 Duration with the unit microseconds.
typedef duration< __intmax_t,
ratio< 1, 1000 > > 
milliseconds
 Duration with the unit milliseconds.
typedef duration< __intmax_t > seconds
 Duration with the unit seconds.
typedef duration< __intmax_t,
ratio< 60 > > 
minutes
 Duration with the unit minutes.
typedef duration< __intmax_t,
ratio< 3600 > > 
hours
 Duration with the unit hours.

Functions

thread::id get_id ()
 Return the thread ID of the calling thread.
void yield ()
 Yield execution to another thread.
template<class _Rep , class _Period >
void sleep_for (const chrono::duration< _Rep, _Period > &aTime)
 Blocks the calling thread for a period of time.

Detailed Description


Define Documentation

#define thread_local

Thread local storage keyword.

A variable that is declared with the thread_local keyword makes the value of the variable local to each thread (known as thread-local storage, or TLS). Example usage:

 // This variable is local to each thread.
 thread_local int variable;
Note:
The thread_local keyword is a macro that maps to the corresponding compiler directive (e.g. __declspec(thread)). While the C++11 standard allows for non-trivial types (e.g. classes with constructors and destructors) to be declared with the thread_local keyword, most pre-C++11 compilers only allow for trivial types (e.g. int). So, to guarantee portable code, only use trivial types for thread local storage.
This directive is currently not supported on Mac OS X (it will give a compiler error), since compile-time TLS is not supported in the Mac OS X executable format. Also, some older versions of MinGW (before GCC 4.x) do not support this directive.