2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
54 private import gthread
.gthreadtypes
;
56 private import lib
.gthread
;
58 private import glib
.Date
;
59 private import gthread
.Mutex
;
63 * Threads act almost like processes, but unlike processes all threads of
64 * one process share the same memory. This is good, as it provides easy
65 * communication between the involved threads via this shared memory, and
66 * it is bad, because strange things (so called "Heisenbugs") might
67 * happen if the program is not carefully designed. In particular, due to
68 * the concurrent nature of threads, no assumptions on the order of
69 * execution of code running in different threads can be made, unless
70 * order is explicitly forced by the programmer through synchronization
72 * The aim of the thread related functions in GLib is to provide a
73 * portable means for writing multi-threaded software. There are
74 * primitives for mutexes to protect the access to portions of memory
75 * (GMutex, GStaticMutex, G_LOCK_DEFINE, GStaticRecMutex and
76 * GStaticRWLock). There are primitives for condition variables to allow
77 * synchronization of threads (GCond). There are primitives
78 * for thread-private data - data that every thread has a private instance of
79 * (GPrivate, GStaticPrivate). Last but definitely not least there are
80 * primitives to portably create and manage threads (GThread).
81 * You must call g_thread_init() before executing any other GLib
82 * functions in a threaded GLib program. After that, GLib is completely
83 * thread safe (all global data is automatically locked), but individual
84 * data structure instances are not automatically locked for performance
85 * reasons. So, for example you must coordinate accesses to the same
86 * GHashTable from multiple threads. The two notable exceptions from
87 * this rule are GMainLoop and GAsyncQueue,
88 * which are threadsafe and needs no further
89 * application-level locking to be accessed from multiple threads.
94 /** the main Gtk struct */
95 protected GCond
* gCond
;
98 public GCond
* getCondStruct()
104 /** the main Gtk struct as a void* */
105 protected void* getStruct()
107 return cast(void*)gCond
;
111 * Sets our main struct and passes it to the parent class
113 public this (GCond
* gCond
)
181 * Creates a new GCond. This function will abort, if g_thread_init()
182 * has not been called yet.
188 // GCond* g_cond_new ();
189 this(cast(GCond
*)g_cond_new() );
193 * If threads are waiting for cond, exactly one of them is woken up. It
194 * is good practice to hold the same lock as the waiting thread while
195 * calling this function, though not required.
196 * This function can be used even if g_thread_init() has not yet been called,
197 * and, in that case, will do nothing.
203 // void g_cond_signal (GCond *cond);
204 g_cond_signal(gCond
);
208 * If threads are waiting for cond, all of them are woken up. It is good
209 * practice to lock the same mutex as the waiting threads, while calling
210 * this function, though not required.
211 * This function can be used even if g_thread_init() has not yet been called,
212 * and, in that case, will do nothing.
216 public void broadcast()
218 // void g_cond_broadcast (GCond *cond);
219 g_cond_broadcast(gCond
);
223 * Waits until this thread is woken up on cond. The mutex is unlocked
224 * before falling asleep and locked again before resuming.
225 * This function can be used even if g_thread_init() has not yet been
226 * called, and, in that case, will immediately return.
230 * a GMutex, that is currently locked.
232 public void wait(Mutex mutex
)
234 // void g_cond_wait (GCond *cond, GMutex *mutex);
235 g_cond_wait(gCond
, (mutex
is null) ?
null : mutex
.getMutexStruct());
239 * Waits until this thread is woken up on cond, but not longer than
240 * until the time specified by abs_time. The mutex is
241 * unlocked before falling asleep and locked again before resuming.
242 * If abs_time is NULL, g_cond_timed_wait() acts like g_cond_wait().
243 * This function can be used even if g_thread_init() has not yet been
244 * called, and, in that case, will immediately return TRUE.
245 * To easily calculate abs_time a combination of g_get_current_time()
246 * and g_time_val_add() can be used.
250 * a GMutex that is currently locked.
252 * a GTimeVal, determining the final time.
254 * TRUE if cond was signalled, or FALSE on timeout.
256 public int timedWait(Mutex mutex
, GTimeVal
* absTime
)
258 // gboolean g_cond_timed_wait (GCond *cond, GMutex *mutex, GTimeVal *abs_time);
259 return g_cond_timed_wait(gCond
, (mutex
is null) ?
null : mutex
.getMutexStruct(), absTime
);
263 * Destroys the GCond.
269 // void g_cond_free (GCond *cond);