I've no idea here...
[gtkD.git] / src / gthread / Private.d
bloba56623caffd21ef7f2e059d5dbcfd32a0cf8bc35
1 /*
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:
25 * inFile =
26 * outPack = gthread
27 * outFile = Private
28 * strct = GPrivate
29 * realStrct=
30 * ctorStrct=
31 * clss = Private
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_private_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.Dataset
45 * structWrap:
46 * - GDataset* -> Dataset
47 * local aliases:
50 module gthread.Private;
52 private import gthread.gthreadtypes;
54 private import lib.gthread;
56 private import glib.Dataset;
58 /**
59 * Description
60 * Threads act almost like processes, but unlike processes all threads of
61 * one process share the same memory. This is good, as it provides easy
62 * communication between the involved threads via this shared memory, and
63 * it is bad, because strange things (so called "Heisenbugs") might
64 * happen if the program is not carefully designed. In particular, due to
65 * the concurrent nature of threads, no assumptions on the order of
66 * execution of code running in different threads can be made, unless
67 * order is explicitly forced by the programmer through synchronization
68 * primitives.
69 * The aim of the thread related functions in GLib is to provide a
70 * portable means for writing multi-threaded software. There are
71 * primitives for mutexes to protect the access to portions of memory
72 * (GMutex, GStaticMutex, G_LOCK_DEFINE, GStaticRecMutex and
73 * GStaticRWLock). There are primitives for condition variables to allow
74 * synchronization of threads (GCond). There are primitives
75 * for thread-private data - data that every thread has a private instance of
76 * (GPrivate, GStaticPrivate). Last but definitely not least there are
77 * primitives to portably create and manage threads (GThread).
78 * You must call g_thread_init() before executing any other GLib
79 * functions in a threaded GLib program. After that, GLib is completely
80 * thread safe (all global data is automatically locked), but individual
81 * data structure instances are not automatically locked for performance
82 * reasons. So, for example you must coordinate accesses to the same
83 * GHashTable from multiple threads. The two notable exceptions from
84 * this rule are GMainLoop and GAsyncQueue,
85 * which are threadsafe and needs no further
86 * application-level locking to be accessed from multiple threads.
88 public class Private
91 /** the main Gtk struct */
92 protected GPrivate* gPrivate;
95 public GPrivate* getPrivateStruct()
97 return gPrivate;
101 /** the main Gtk struct as a void* */
102 protected void* getStruct()
104 return cast(void*)gPrivate;
108 * Sets our main struct and passes it to the parent class
110 public this (GPrivate* gPrivate)
112 this.gPrivate = gPrivate;
185 * Creates a new GPrivate. If destructor is non-NULL, it is a pointer
186 * to a destructor function. Whenever a thread ends and the corresponding
187 * pointer keyed to this instance of GPrivate is non-NULL, the
188 * destructor is called with this pointer as the argument.
189 * Note
190 * destructor is used quite differently from notify in
191 * g_static_private_set().
192 * Note
193 * A GPrivate can not be freed. Reuse it instead, if you can, to avoid
194 * shortage, or use GStaticPrivate.
195 * Note
196 * This function will abort if g_thread_init() has not been called yet.
197 * destructor:
198 * a function to destroy the data keyed to GPrivate when a
199 * thread ends.
200 * Returns:
201 * a new GPrivate.
203 public this (GDestroyNotify destructor)
205 // GPrivate* g_private_new (GDestroyNotify destructor);
206 this(cast(GPrivate*)g_private_new(destructor) );
210 * Returns the pointer keyed to private_key for the current thread.
211 * If g_private_set() hasn't been called for the
212 * current private_key and thread yet, this pointer will be NULL.
213 * This function can be used even if g_thread_init() has not yet been
214 * called, and, in that case, will return the value of private_key casted to gpointer.
215 * private_key:
216 * a GPrivate.
217 * Returns:
218 * the corresponding pointer.
220 public void* get()
222 // gpointer g_private_get (GPrivate *private_key);
223 return g_private_get(gPrivate);
227 * Sets the pointer keyed to private_key for the current thread.
228 * This function can be used even if g_thread_init() has not yet been
229 * called, and, in that case, will set private_key to data casted to GPrivate*.
230 * private_key:
231 * a GPrivate.
232 * data:
233 * the new pointer.
235 public void set(void* data)
237 // void g_private_set (GPrivate *private_key, gpointer data);
238 g_private_set(gPrivate, data);