glibmm: Threads

# Threads

Thread abstraction; including threads, different mutexes, conditions and thread private data. More...

## Classes
class | Glib::ThreadError
| Exception class for thread-related errors. More...
class | Glib::Thread
| Represents a running thread. More...
class | Glib::Thread::Exit
| Exception class used to exit from a thread. More...
struct | Glib::StaticMutex
| Like Glib::Mutex, but can be defined at compile time. More...
class | Glib::Mutex
| Represents a mutex (mutual exclusion). More...
class | Glib::Mutex::Lock
| Utility class for exception-safe mutex locking. More...
struct | Glib::StaticRecMutex
| Like Glib::RecMutex, but can be defined at compile time. More...
class | Glib::RecMutex
class | Glib::RecMutex::Lock
| Utility class for exception-safe locking of recursive mutexes. More...
struct | Glib::StaticRWLock
| Like Glib::RWLock, but can be defined at compile time. More...
class | Glib::RWLock
class | Glib::RWLock::ReaderLock
| Utility class for exception-safe locking of read/write locks. More...
class | Glib::RWLock::WriterLock
| Utility class for exception-safe locking of read/write locks. More...
class | Glib::Cond
| An opaque data structure to represent a condition. More...
struct | Glib::StaticPrivate< T >
class | Glib::Private< T >
class | Glib::Dispatcher
| Signal class for inter-thread communication. More...
## Enumerations
enum | Glib::NotLock { Glib::NOT_LOCK }
enum | Glib::TryLock { Glib::TRY_LOCK }
## Functions
void | Glib::thread_init (GThreadFunctions* vtable=0)
| Initializes the GLib thread system.
bool | Glib::thread_supported ()
| Returns whether the thread system is initialized.
Thread* | Glib::Thread::wrap (GThread* gobject)

## Detailed Description

Thread abstraction; including threads, different mutexes, conditions and thread private data.

## Enumeration Type Documentation

enum Glib::NotLock

Enumerator:

  NOT_LOCK |

enum Glib::TryLock

Enumerator:

  TRY_LOCK |

## Function Documentation

void Glib::thread_init | ( | GThreadFunctions * | vtable = `0` | ) | `[inline]`

Initializes the GLib thread system.

Before you use a thread related function in glibmm, you should initialize the thread system. This is done by calling Glib::thread_init().

Note:
  You should only call thread_init() with a non-`0` parameter if you really know what you are doing.
  thread_init() must not be called directly or indirectly as a callback from glibmm. Also no mutexes may be currently locked while calling thread_init().

thread_init() might only be called once. On the second call it will abort with an error. If you want to make sure that the thread system is initialized, you can do that too:

     if(!Glib::thread_supported()) Glib::thread_init();

After that line either the thread system is initialized, or the program will abort if no thread system is available in GLib, i.e. either `G_THREADS_ENABLED` is not defined or `G_THREADS_IMPL_NONE` is defined.

If no thread system is available and vtable is `0` or if not all elements of vtable are non-`0`, then thread_init() will abort.

Note:
  To use thread_init() in your program, you have to link with the libraries that the command `pkg-config --libs gthread-2.0` outputs. This is not the case for all the other thread related functions of glibmm. Those can be used without having to link with the thread libraries. (You have to link with `gthread-2.0` if you actually want to use threads in your application, though.)

Parameters:

  | vtable | A function table of type `GThreadFunctions`, that provides the entry points to the thread system to be used.

Examples:
  thread/dispatcher.cc, and thread/thread.cc.

bool Glib::thread_supported | ( |  | ) | `[inline]`

Returns whether the thread system is initialized.

Returns:
  `true`, if the thread system is initialized.

Thread * wrap | ( | GThread * | gobject | ) | `[related, inherited]`