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:
27 * outFile = StaticRecMutex
28 * strct = GStaticRecMutex
31 * clss = StaticRecMutex
39 * - g_static_rec_mutex_
48 module gthread
.StaticRecMutex
;
50 private import gthread
.gthreadtypes
;
52 private import lib
.gthread
;
57 * Threads act almost like processes, but unlike processes all threads of
58 * one process share the same memory. This is good, as it provides easy
59 * communication between the involved threads via this shared memory, and
60 * it is bad, because strange things (so called "Heisenbugs") might
61 * happen if the program is not carefully designed. In particular, due to
62 * the concurrent nature of threads, no assumptions on the order of
63 * execution of code running in different threads can be made, unless
64 * order is explicitly forced by the programmer through synchronization
66 * The aim of the thread related functions in GLib is to provide a
67 * portable means for writing multi-threaded software. There are
68 * primitives for mutexes to protect the access to portions of memory
69 * (GMutex, GStaticMutex, G_LOCK_DEFINE, GStaticRecMutex and
70 * GStaticRWLock). There are primitives for condition variables to allow
71 * synchronization of threads (GCond). There are primitives
72 * for thread-private data - data that every thread has a private instance of
73 * (GPrivate, GStaticPrivate). Last but definitely not least there are
74 * primitives to portably create and manage threads (GThread).
75 * You must call g_thread_init() before executing any other GLib
76 * functions in a threaded GLib program. After that, GLib is completely
77 * thread safe (all global data is automatically locked), but individual
78 * data structure instances are not automatically locked for performance
79 * reasons. So, for example you must coordinate accesses to the same
80 * GHashTable from multiple threads. The two notable exceptions from
81 * this rule are GMainLoop and GAsyncQueue,
82 * which are threadsafe and needs no further
83 * application-level locking to be accessed from multiple threads.
85 public class StaticRecMutex
88 /** the main Gtk struct */
89 protected GStaticRecMutex
* gStaticRecMutex
;
92 public GStaticRecMutex
* getStaticRecMutexStruct()
94 return gStaticRecMutex
;
98 /** the main Gtk struct as a void* */
99 protected void* getStruct()
101 return cast(void*)gStaticRecMutex
;
105 * Sets our main struct and passes it to the parent class
107 public this (GStaticRecMutex
* gStaticRecMutex
)
109 this.gStaticRecMutex
= gStaticRecMutex
;
157 * A GStaticRecMutex must be initialized with this function before it
158 * can be used. Alternatively you can initialize it with
159 * G_STATIC_REC_MUTEX_INIT.
161 * a GStaticRecMutex to be initialized.
165 // void g_static_rec_mutex_init (GStaticRecMutex *mutex);
166 g_static_rec_mutex_init(gStaticRecMutex
);
170 * Locks mutex. If mutex is already locked by another thread, the
171 * current thread will block until mutex is unlocked by the other
172 * thread. If mutex is already locked by the calling thread, this
173 * functions increases the depth of mutex and returns immediately.
175 * a GStaticRecMutex to lock.
179 // void g_static_rec_mutex_lock (GStaticRecMutex *mutex);
180 g_static_rec_mutex_lock(gStaticRecMutex
);
184 * Tries to lock mutex. If mutex is already locked by another thread,
185 * it immediately returns FALSE. Otherwise it locks mutex and returns
186 * TRUE. If mutex is already locked by the calling thread, this
187 * functions increases the depth of mutex and immediately returns TRUE.
189 * a GStaticRecMutex to lock.
191 * TRUE, if mutex could be locked.
195 // gboolean g_static_rec_mutex_trylock (GStaticRecMutex *mutex);
196 return g_static_rec_mutex_trylock(gStaticRecMutex
);
200 * Unlocks mutex. Another thread can will be allowed to lock mutex only
201 * when it has been unlocked as many times as it had been locked
202 * before. If mutex is completely unlocked and another thread is blocked
203 * in a g_static_rec_mutex_lock() call for mutex, it will be woken and
204 * can lock mutex itself.
206 * a GStaticRecMutex to unlock.
210 // void g_static_rec_mutex_unlock (GStaticRecMutex *mutex);
211 g_static_rec_mutex_unlock(gStaticRecMutex
);
215 * Works like calling g_static_rec_mutex_lock() for mutex depth times.
217 * a GStaticRecMutex to lock.
219 * number of times this mutex has to be unlocked to be completely unlocked.
221 public void lockFull(uint depth
)
223 // void g_static_rec_mutex_lock_full (GStaticRecMutex *mutex, guint depth);
224 g_static_rec_mutex_lock_full(gStaticRecMutex
, depth
);
228 * Completely unlocks mutex. If another thread is blocked in a
229 * g_static_rec_mutex_lock() call for mutex, it will be woken and can
230 * lock mutex itself. This function returns the number of times that
231 * mutex has been locked by the current thread. To restore the state
232 * before the call to g_static_rec_mutex_unlock_full() you can call
233 * g_static_rec_mutex_lock_full() with the depth returned by this
236 * a GStaticRecMutex to completely unlock.
238 * number of times mutex has been locked by the current thread.
240 public uint unlockFull()
242 // guint g_static_rec_mutex_unlock_full (GStaticRecMutex *mutex);
243 return g_static_rec_mutex_unlock_full(gStaticRecMutex
);
247 * Releases all resources allocated to a GStaticRecMutex.
248 * You don't have to call this functions for a GStaticRecMutex with an
249 * unbounded lifetime, i.e. objects declared 'static', but if you have a
250 * GStaticRecMutex as a member of a structure and the structure is
251 * freed, you should also free the GStaticRecMutex.
253 * a GStaticRecMutex to be freed.
257 // void g_static_rec_mutex_free (GStaticRecMutex *mutex);
258 g_static_rec_mutex_free(gStaticRecMutex
);