Libraries:Gtk:Glib:GThread
Types
T
Constants
Nil : T
Functions
CreateFull(func @ Std.Function.T, data @ Std.Address.T, stack_size @ Std.Integer.SmallT, joinable @ Std.Symbol.T, bound @ Std.Symbol.T, priority @ Gtk.Glib.GThreadPriority.T, error @ Std.Object.T) : Gtk.Glib.GThread.T
This function creates a new thread with the priority priority. If the underlying thread implementation supports it, the thread gets a stack size of stack_size or the default value for the current platform, if stack_size is 0.
If joinable is TRUE, you can wait for this threads termination calling Join. Otherwise the thread will just disappear when it terminates. If bound is TRUE, this thread will be scheduled in the system scope, otherwise the implementation is free to do scheduling in the process scope. The first variant is more expensive resource-wise, but generally faster. On some systems (e.g. Linux) all threads are bound.
The new thread executes the function func with the argument data. If the thread was created successfully, it is returned.
error can be NULL to ignore errors, or non-NULL to report errors. The error is set, if and only if the function returns NULL.
Note
It is not guaranteed that threads with different priorities really behave accordingly. On some systems (e.g. Linux) there are no thread priorities. On other systems (e.g. Solaris) there doesn't seem to be different scheduling for different priorities. All in all try to avoid being dependent on priorities. Use Gtk.Glib.GThreadPriority.Normal here as a default.
Exit(retval @ Std.Address.T) : Std.Object.T
Exits the current thread. If another thread is waiting for that thread using Join and the current thread is joinable, the waiting thread will be woken up and get retval as the return value of Join. If the current thread is not joinable, retval is ignored. Calling
1 |
g_thread_exit (retval); |
Foreach(thread_func @ Std.Function.T, user_data @ Std.Object.T) : Std.Object.T
Call thread_func on all existing T structures. Note that threads may decide to exit while thread_func is running, so without intimate knowledge about the lifetime of foreign threads, thread_func shouldn't access the GThread* pointer passed in as first argument. However, thread_func will not be called for threads which are known to have exited already.
Due to thread lifetime checks, this function has an execution complexity which is quadratic in the number of existing threads.
thread_func | function to call for all GThread structures |
user_data | second argument to thread_func |
GetInitialized() : Std.Symbol.T
Init(vtable @ Gtk.Glib.GThreadFunctions.T) : Std.Object.T
If you use GLib from more than one thread, you must initialize the thread system by calling Init. Most of the time you will only have to call g_thread_init (NULL).
InitWithErrorcheckMutexes(vtable @ Gtk.Glib.GThreadFunctions.T) : Std.Object.T
Self() : Gtk.Glib.GThread.T
_Alloc() : Gtk.Glib.GThread.T
Methods
:"="(_ @ T, _ @ T)
:Join(self @ T) : Std.Address.T
Waits until thread finishes, i.e. the function func, as given to g_thread_create(), returns or Exit is called by thread. All resources of thread including the T struct are released. thread must have been created with joinable=TRUE in g_thread_create(). The value returned by func or given to Exit by thread is returned by this function.
thread | a T to be waited for. |
Returns | the return value of the thread. |
:SetPriority(self @ T, priority @ Gtk.Glib.GThreadPriority.T) : Std.Object.T
Changes the priority of thread to priority.
Note
It is not guaranteed that threads with different priorities really behave accordingly. On some systems (e.g. Linux) there are no thread priorities. On other systems (e.g. Solaris) there doesn't seem to be different scheduling for different priorities. All in all try to avoid being dependent on priorities.