![]() |
![]() |
An instance of this class can only be obtained with create(), self(), or wrap(GThread*). It's not possible to delete a Thread object. If the thread is not joinable, its resources will be freed automatically when it exits. Otherwise, if the thread is joinable, you must call join() to avoid a memory leak.
You might have noticed that the thread entry slot doesn't have the usual void* return value. If you want to return any data from your thread you can pass an additional output argument to the thread's entry slot.
Public Member Functions | |
bool | joinable () const |
Returns whether the thread is joinable. | |
void | join () |
Waits until the thread finishes. | |
void | set_priority (ThreadPriority priority) |
Changes the priority of the thread to priority. | |
ThreadPriority | get_priority () const |
Returns the priority of the thread. | |
GThread* | gobj () |
const GThread* | gobj () const |
Static Public Member Functions | |
Thread* | create (const SigC::Slot0<void>& slot, bool joinable) |
Creates a new thread with the priority THREAD_PRIORITY_NORMAL . | |
Thread* | create (const SigC::Slot0<void>& slot, unsigned long stack_size, bool joinable, bool bound, ThreadPriority priority) |
Creates a new thread with the priority priority. | |
Thread* | self () |
Returns the Thread* corresponding to the calling thread. | |
void | yield () |
Gives way to other threads waiting to be scheduled. | |
Related Functions | |
(Note that these are not member functions.) | |
Thread* | wrap (GThread* gobject) |
|
Creates a new thread with the priority priority.
The stack gets the size stack_size or the default value for the current platform, if stack_size is
If joinable is The new thread executes the function or method slot points to. You can pass additional arguments using SigC::bind(). If the thread was created successfully, it is returned.
|
|
Creates a new thread with the priority
If joinable is The new thread executes the function or method slot points to. You can pass additional arguments using SigC::bind(). If the thread was created successfully, it is returned, otherwise a ThreadError exception is thrown.
|
|
Returns the priority of the thread.
|
|
|
|
|
|
Waits until the thread finishes.
Waits until the thread finishes, i.e. the slot, as given to create(), returns or g_thread_exit() is called by the thread. (Calling g_thread_exit() in a C++ program should be avoided.) All resources of the thread including the Glib::Thread object are released. The thread must have been created with
|
|
Returns whether the thread is joinable.
|
|
Returns the Thread* corresponding to the calling thread.
|
|
Changes the priority of the thread to priority.
|
|
Gives way to other threads waiting to be scheduled. This function is often used as a method to make busy wait less evil. But in most cases, you will encounter, there are better methods to do that. So in general you shouldn't use this function. |