I've no idea here...
[gtkD.git] / src / gthread / StaticPrivate.d
blob16d826f1b1e3ce65b9858850e58cc1245286dd85
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 = StaticPrivate
28 * strct = GStaticPrivate
29 * realStrct=
30 * ctorStrct=
31 * clss = StaticPrivate
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_static_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.StaticPrivate;
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 StaticPrivate
91 /** the main Gtk struct */
92 protected GStaticPrivate* gStaticPrivate;
95 public GStaticPrivate* getStaticPrivateStruct()
97 return gStaticPrivate;
101 /** the main Gtk struct as a void* */
102 protected void* getStruct()
104 return cast(void*)gStaticPrivate;
108 * Sets our main struct and passes it to the parent class
110 public this (GStaticPrivate* gStaticPrivate)
112 this.gStaticPrivate = gStaticPrivate;
190 * Initializes private_key. Alternatively you can initialize it with
191 * G_STATIC_PRIVATE_INIT.
192 * private_key:
193 * a GStaticPrivate to be initialized.
195 public void init()
197 // void g_static_private_init (GStaticPrivate *private_key);
198 g_static_private_init(gStaticPrivate);
202 * Works like g_private_get() only for a GStaticPrivate.
203 * This function works even if g_thread_init() has not yet been called.
204 * private_key:
205 * a GStaticPrivate.
206 * Returns:
207 * the corresponding pointer.
209 public void* get()
211 // gpointer g_static_private_get (GStaticPrivate *private_key);
212 return g_static_private_get(gStaticPrivate);
216 * Sets the pointer keyed to private_key for the current thread and the
217 * function notify to be called with that pointer (NULL or non-NULL),
218 * whenever the pointer is set again or whenever the current thread ends.
219 * This function works even if g_thread_init() has not yet been
220 * called. If g_thread_init() is called later, the data keyed to
221 * private_key will be inherited only by the main thread, i.e. the one that
222 * called g_thread_init().
223 * Note
224 * notify is used quite differently from destructor in
225 * g_private_new().
226 * private_key:
227 * a GStaticPrivate.
228 * data:
229 * the new pointer.
230 * notify:
231 * a function to be called with the pointer whenever the
232 * current thread ends or sets this pointer again.
234 public void set(void* data, GDestroyNotify notify)
236 // void g_static_private_set (GStaticPrivate *private_key, gpointer data, GDestroyNotify notify);
237 g_static_private_set(gStaticPrivate, data, notify);
241 * Releases all resources allocated to private_key.
242 * You don't have to call this functions for a GStaticPrivate with an
243 * unbounded lifetime, i.e. objects declared 'static', but if you have a
244 * GStaticPrivate as a member of a structure and the structure is freed,
245 * you should also free the GStaticPrivate.
246 * private_key:
247 * a GStaticPrivate to be freed.
249 public void free()
251 // void g_static_private_free (GStaticPrivate *private_key);
252 g_static_private_free(gStaticPrivate);