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.


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...


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.


 TinyThread++ version (major number).
 TinyThread++ version (minor number).
 TinyThread++ version (full version).
#define thread_local
 Thread local storage keyword.


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


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;
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.