1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 module gtkc.gthreadtypes;
25 
26 
27 public import gtkc.glibtypes;
28 
29 /**
30  * Possible errors of thread related functions.
31  * G_THREAD_ERROR_AGAIN
32  * a thread couldn't be created due to resource
33  *  shortage. Try again later.
34  */
35 public enum GThreadError
36 {
37 	AGAIN /+* Resource temporarily unavailable +/
38 }
39 alias GThreadError ThreadError;
40 
41 /**
42  * The possible statuses of a one-time initialization function
43  * controlled by a GOnce struct.
44  * G_ONCE_STATUS_NOTCALLED
45  * the function has not been called yet.
46  * G_ONCE_STATUS_PROGRESS
47  * the function call is currently in progress.
48  * G_ONCE_STATUS_READY
49  * the function has been called.
50  * Since 2.4
51  */
52 public enum GOnceStatus
53 {
54 	NOTCALLED,
55 	PROGRESS,
56 	READY
57 }
58 alias GOnceStatus OnceStatus;
59 
60 
61 /**
62  * Main Gtk struct.
63  * The GThread struct represents a running thread. This struct
64  * is returned by g_thread_new() or g_thread_try_new(). You can
65  * obtain the GThread struct representing the current thead by
66  * calling g_thread_self().
67  * GThread is refcounted, see g_thread_ref() and g_thread_unref().
68  * The thread represented by it holds a reference while it is running,
69  * and g_thread_join() consumes the reference that it is given, so
70  * it is normally not necessary to manage GThread references
71  * explicitly.
72  * The structure is opaque -- none of its fields may be directly
73  * accessed.
74  */
75 public struct GThread{}
76 
77 
78 /**
79  * The GRecMutex struct is an opaque data structure to represent a
80  * recursive mutex. It is similar to a GMutex with the difference
81  * that it is possible to lock a GRecMutex multiple times in the same
82  * thread without deadlock. When doing so, care has to be taken to
83  * unlock the recursive mutex as often as it has been locked.
84  * If a GRecMutex is allocated in static storage then it can be used
85  * without initialisation. Otherwise, you should call
86  * g_rec_mutex_init() on it and g_rec_mutex_clear() when done.
87  * A GRecMutex should only be accessed with the
88  * g_rec_mutex_ functions.
89  * Since 2.32
90  */
91 public struct GRecMutex{}
92 
93 
94 /**
95  * The GRWLock struct is an opaque data structure to represent a
96  * reader-writer lock. It is similar to a GMutex in that it allows
97  * multiple threads to coordinate access to a shared resource.
98  * The difference to a mutex is that a reader-writer lock discriminates
99  * between read-only ('reader') and full ('writer') access. While only
100  * one thread at a time is allowed write access (by holding the 'writer'
101  * lock via g_rw_lock_writer_lock()), multiple threads can gain
102  * simultaneous read-only access (by holding the 'reader' lock via
103  * g_rw_lock_reader_lock()).
104  * $(DDOC_COMMENT example)
105  * If a GRWLock is allocated in static storage then it can be used
106  * without initialisation. Otherwise, you should call
107  * g_rw_lock_init() on it and g_rw_lock_clear() when done.
108  * A GRWLock should only be accessed with the
109  * g_rw_lock_ functions.
110  * Since 2.32
111  */
112 public struct GRWLock{}
113 
114 
115 /**
116  * The GCond struct is an opaque data structure that represents a
117  * condition. Threads can block on a GCond if they find a certain
118  * condition to be false. If other threads change the state of this
119  * condition they signal the GCond, and that causes the waiting
120  * threads to be woken up.
121  * Consider the following example of a shared variable. One or more
122  * threads can wait for data to be published to the variable and when
123  * another thread publishes the data, it can signal one of the waiting
124  * threads to wake up to collect the data.
125  * $(DDOC_COMMENT example)
126  * Whenever a thread calls pop_data() now, it will wait until
127  * current_data is non-NULL, i.e. until some other thread
128  * has called push_data().
129  * The example shows that use of a condition variable must always be
130  * paired with a mutex. Without the use of a mutex, there would be a
131  * race between the check of current_data by the
132  * while loop in pop_data and waiting.
133  * Specifically, another thread could set pop_data
134  * after the check, and signal the cond (with nobody waiting on it)
135  * before the first thread goes to sleep. GCond is specifically useful
136  * for its ability to release the mutex and go to sleep atomically.
137  * It is also important to use the g_cond_wait() and g_cond_wait_until()
138  * functions only inside a loop which checks for the condition to be
139  * true. See g_cond_wait() for an explanation of why the condition may
140  * not be true even after it returns.
141  * If a GCond is allocated in static storage then it can be used
142  * without initialisation. Otherwise, you should call g_cond_init() on
143  * it and g_cond_clear() when done.
144  * A GCond should only be accessed via the g_cond_
145  * functions.
146  */
147 public struct GCond{}
148 
149 
150 /**
151  * The GPrivate struct is an opaque data structure to represent a
152  * thread-local data key. It is approximately equivalent to the
153  * pthread_setspecific()/pthread_getspecific() APIs on POSIX and to
154  * TlsSetValue()/TlsGetValue() on Windows.
155  * If you don't already know why you might want this functionality,
156  * then you probably don't need it.
157  * GPrivate is a very limited resource (as far as 128 per program,
158  * shared between all libraries). It is also not possible to destroy a
159  * GPrivate after it has been used. As such, it is only ever acceptable
160  * to use GPrivate in static scope, and even then sparingly so.
161  * See G_PRIVATE_INIT() for a couple of examples.
162  * The GPrivate structure should be considered opaque. It should only
163  * be accessed via the g_private_ functions.
164  */
165 public struct GPrivate{}
166 
167 
168 /**
169  * A GOnce struct controls a one-time initialization function. Any
170  * one-time initialization function must have its own unique GOnce
171  * struct.
172  * volatile GOnceStatus status;
173  * the status of the GOnce
174  * volatile gpointer retval;
175  * the value returned by the call to the function, if status
176  * is G_ONCE_STATUS_READY
177  * Since 2.4
178  */
179 public struct GOnce
180 {
181 	GOnceStatus status;
182 	void* retval;
183 }
184 
185 
186 /*
187  * The G_LOCK_* macros provide a convenient interface to GMutex.
188  * G_LOCK_DEFINE defines a lock. It can appear in any place where
189  * variable definitions may appear in programs, i.e. in the first block
190  * of a function or outside of functions. The name parameter will be
191  * mangled to get the name of the GMutex. This means that you
192  * can use names of existing variables as the parameter - e.g. the name
193  * of the variable you intend to protect with the lock. Look at our
194  * give_me_next_number() example using the
195  * G_LOCK_* macros:
196  * $(DDOC_COMMENT example)
197  * name :
198  * the name of the lock
199  */
200 // TODO
201 // #define G_LOCK_DEFINE(name)
202 
203 /*
204  * This works like G_LOCK_DEFINE, but it creates a static object.
205  * name :
206  * the name of the lock
207  */
208 // TODO
209 // #define G_LOCK_DEFINE_STATIC(name)
210 
211 /*
212  * This declares a lock, that is defined with G_LOCK_DEFINE in another
213  * module.
214  * name :
215  * the name of the lock
216  */
217 // TODO
218 // #define G_LOCK_EXTERN(name)
219 
220 /*
221  * Works like g_mutex_lock(), but for a lock defined with
222  * G_LOCK_DEFINE.
223  * name :
224  * the name of the lock
225  */
226 // TODO
227 // #define G_LOCK(name)
228 
229 /*
230  * Works like g_mutex_trylock(), but for a lock defined with
231  * G_LOCK_DEFINE.
232  * name :
233  * the name of the lock
234  * Returns :
235  * TRUE, if the lock could be locked.
236  */
237 // TODO
238 // #define G_TRYLOCK(name)
239 
240 /*
241  * Works like g_mutex_unlock(), but for a lock defined with
242  * G_LOCK_DEFINE.
243  * name :
244  * the name of the lock
245  */
246 // TODO
247 // #define G_UNLOCK(name)
248 
249 /*
250  * A macro to assist with the static initialisation of a GPrivate.
251  * This macro is useful for the case that a GDestroyNotify function
252  * should be associated the key. This is needed when the key will be
253  * used to point at memory that should be deallocated when the thread
254  * exits.
255  * Additionally, the GDestroyNotify will also be called on the previous
256  * value stored in the key when g_private_replace() is used.
257  * If no GDestroyNotify is needed, then use of this macro is not
258  * required -- if the GPrivate is declared in static scope then it will
259  * be properly initialised by default (ie: to all zeros). See the
260  * examples below.
261  * $(DDOC_COMMENT example)
262  * notify :
263  * a GDestroyNotify
264  * Since 2.32
265  */
266 // TODO
267 // #define G_PRIVATE_INIT(notify)
268 
269 /*
270  * The first call to this routine by a process with a given GOnce
271  * struct calls func with the given argument. Thereafter, subsequent
272  * calls to g_once() with the same GOnce struct do not call func
273  * again, but return the stored result of the first call. On return
274  * from g_once(), the status of once will be G_ONCE_STATUS_READY.
275  * For example, a mutex or a thread-specific data key must be created
276  * exactly once. In a threaded environment, calling g_once() ensures
277  * that the initialization is serialized across multiple threads.
278  * Calling g_once() recursively on the same GOnce struct in
279  * func will lead to a deadlock.
280  * $(DDOC_COMMENT example)
281  * once :
282  * a GOnce structure
283  * func :
284  * the GThreadFunc function associated to once. This function
285  * is called only once, regardless of the number of times it and
286  * its associated GOnce struct are passed to g_once().
287  * arg :
288  * data to be passed to func
289  * Since 2.4
290  */
291 // TODO
292 // #define g_once(once, func, arg)
293 
294 /*
295  * Specifies the type of the func functions passed to g_thread_new()
296  * or g_thread_try_new().
297  * data :
298  * data passed to the thread
299  * Returns :
300  * the return value of the thread
301  */
302 // gpointer (*GThreadFunc) (gpointer data);
303 public alias extern(C) void* function(void* data) GThreadFunc;
304 /**
305  * The GMutex struct is an opaque data structure to represent a mutex
306  * (mutual exclusion). It can be used to protect data against shared
307  * access. Take for example the following function:
308  * $(DDOC_COMMENT example)
309  * It is easy to see that this won't work in a multi-threaded
310  * application. There current_number must be protected against shared
311  * access. A GMutex can be used as a solution to this problem:
312  * $(DDOC_COMMENT example)
313  * Notice that the GMutex is not initialised to any particular value.
314  * Its placement in static storage ensures that it will be initialised
315  * to all-zeros, which is appropriate.
316  * If a GMutex is placed in other contexts (eg: embedded in a struct)
317  * then it must be explicitly initialised using g_mutex_init().
318  * A GMutex should only be accessed via g_mutex_
319  * functions.
320  */
321 public struct GMutex
322 {
323 	union
324 	{
325 		/+*< private >+/
326 		void* p;
327 		uint i[2];
328 	}
329 }