2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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:
46 * - GDataset* -> Dataset
51 module gthread
.Private
;
57 import tango
.io
.Stdout
; // use the tango loging?
61 private import gtkc
.gthreadtypes
;
63 private import gtkc
.gthread
;
66 private import glib
.Dataset
;
73 * Threads act almost like processes, but unlike processes all threads of
74 * one process share the same memory. This is good, as it provides easy
75 * communication between the involved threads via this shared memory, and
76 * it is bad, because strange things (so called "Heisenbugs") might
77 * happen if the program is not carefully designed. In particular, due to
78 * the concurrent nature of threads, no assumptions on the order of
79 * execution of code running in different threads can be made, unless
80 * order is explicitly forced by the programmer through synchronization
82 * The aim of the thread related functions in GLib is to provide a
83 * portable means for writing multi-threaded software. There are
84 * primitives for mutexes to protect the access to portions of memory
85 * (GMutex, GStaticMutex, G_LOCK_DEFINE, GStaticRecMutex and
86 * GStaticRWLock). There are primitives for condition variables to allow
87 * synchronization of threads (GCond). There are primitives
88 * for thread-private data - data that every thread has a private instance of
89 * (GPrivate, GStaticPrivate). Last but definitely not least there are
90 * primitives to portably create and manage threads (GThread).
91 * You must call g_thread_init() before executing any other GLib
92 * functions in a threaded GLib program. After that, GLib is completely
93 * thread safe (all global data is automatically locked), but individual
94 * data structure instances are not automatically locked for performance
95 * reasons. So, for example you must coordinate accesses to the same
96 * GHashTable from multiple threads. The two notable exceptions from
97 * this rule are GMainLoop and GAsyncQueue,
98 * which are threadsafe and needs no further
99 * application-level locking to be accessed from multiple threads.
104 /** the main Gtk struct */
105 protected GPrivate
* gPrivate
;
108 public GPrivate
* getPrivateStruct()
114 /** the main Gtk struct as a void* */
115 protected void* getStruct()
117 return cast(void*)gPrivate
;
121 * Sets our main struct and passes it to the parent class
123 public this (GPrivate
* gPrivate
)
127 if ( gPrivate
is null )
132 Stdout("struct gPrivate is null on constructor").newline
;
136 printf("struct gPrivate is null on constructor");
143 assert(gPrivate
!is null, "struct gPrivate is null on constructor");
145 this.gPrivate
= gPrivate
;
218 * Creates a new GPrivate. If destructor is non-NULL, it is a pointer
219 * to a destructor function. Whenever a thread ends and the corresponding
220 * pointer keyed to this instance of GPrivate is non-NULL, the
221 * destructor is called with this pointer as the argument.
223 * destructor is used quite differently from notify in
224 * g_static_private_set().
226 * A GPrivate can not be freed. Reuse it instead, if you can, to avoid
227 * shortage, or use GStaticPrivate.
229 * This function will abort if g_thread_init() has not been called yet.
231 * a function to destroy the data keyed to GPrivate when a
236 public this (GDestroyNotify destructor
)
238 // GPrivate* g_private_new (GDestroyNotify destructor);
239 this(cast(GPrivate
*)g_private_new(destructor
) );
243 * Returns the pointer keyed to private_key for the current thread.
244 * If g_private_set() hasn't been called for the
245 * current private_key and thread yet, this pointer will be NULL.
246 * This function can be used even if g_thread_init() has not yet been
247 * called, and, in that case, will return the value of private_key casted to gpointer.
251 * the corresponding pointer.
255 // gpointer g_private_get (GPrivate *private_key);
256 return g_private_get(gPrivate
);
260 * Sets the pointer keyed to private_key for the current thread.
261 * This function can be used even if g_thread_init() has not yet been
262 * called, and, in that case, will set private_key to data casted to GPrivate*.
268 public void set(void* data
)
270 // void g_private_set (GPrivate *private_key, gpointer data);
271 g_private_set(gPrivate
, data
);