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 /*
25  * Conversion parameters:
26  * inFile  = 
27  * outPack = gthread
28  * outFile = StaticPrivate
29  * strct   = GStaticPrivate
30  * realStrct=
31  * ctorStrct=
32  * clss    = StaticPrivate
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_static_private_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * structWrap:
47  * module aliases:
48  * local aliases:
49  * overrides:
50  */
51 
52 module gthread.StaticPrivate;
53 
54 public  import gtkc.gthreadtypes;
55 
56 private import gtkc.gthread;
57 private import glib.ConstructionException;
58 
59 
60 
61 
62 
63 
64 /**
65  * Description
66  * Threads act almost like processes, but unlike processes all threads
67  * of one process share the same memory. This is good, as it provides
68  * easy communication between the involved threads via this shared
69  * memory, and it is bad, because strange things (so called
70  * "Heisenbugs") might happen if the program is not carefully designed.
71  * In particular, due to the concurrent nature of threads, no
72  * assumptions on the order of execution of code running in different
73  * threads can be made, unless order is explicitly forced by the
74  * programmer through synchronization primitives.
75  * The aim of the thread related functions in GLib is to provide a
76  * portable means for writing multi-threaded software. There are
77  * primitives for mutexes to protect the access to portions of memory
78  * (GMutex, GStaticMutex, G_LOCK_DEFINE, GStaticRecMutex and
79  * GStaticRWLock). There are primitives for condition variables to
80  * allow synchronization of threads (GCond). There are primitives for
81  * thread-private data - data that every thread has a private instance
82  * of (GPrivate, GStaticPrivate). Last but definitely not least there
83  * are primitives to portably create and manage threads (GThread).
84  * The threading system is initialized with g_thread_init(), which
85  * takes an optional custom thread implementation or NULL for the
86  * default implementation. If you want to call g_thread_init() with a
87  * non-NULL argument this must be done before executing any other GLib
88  * functions (except g_mem_set_vtable()). This is a requirement even if
89  * no threads are in fact ever created by the process.
90  * Calling g_thread_init() with a NULL argument is somewhat more
91  * relaxed. You may call any other glib functions in the main thread
92  * before g_thread_init() as long as g_thread_init() is not called from
93  * a glib callback, or with any locks held. However, many libraries
94  * above glib does not support late initialization of threads, so doing
95  * this should be avoided if possible.
96  * Please note that since version 2.24 the GObject initialization
97  * function g_type_init() initializes threads (with a NULL argument),
98  * so most applications, including those using Gtk+ will run with
99  * threads enabled. If you want a special thread implementation, make
100  * sure you call g_thread_init() before g_type_init() is called.
101  * After calling g_thread_init(), GLib is completely thread safe (all
102  * global data is automatically locked), but individual data structure
103  * instances are not automatically locked for performance reasons. So,
104  * for example you must coordinate accesses to the same GHashTable
105  * from multiple threads. The two notable exceptions from this rule
106  * are GMainLoop and GAsyncQueue, which are
107  * threadsafe and need no further application-level locking to be
108  * accessed from multiple threads.
109  * To help debugging problems in multithreaded applications, GLib
110  * supports error-checking mutexes that will give you helpful error
111  * messages on common problems. To use error-checking mutexes, define
112  * the symbol G_ERRORCHECK_MUTEXES when compiling the application.
113  */
114 public class StaticPrivate
115 {
116 	
117 	/** the main Gtk struct */
118 	protected GStaticPrivate* gStaticPrivate;
119 	
120 	
121 	public GStaticPrivate* getStaticPrivateStruct()
122 	{
123 		return gStaticPrivate;
124 	}
125 	
126 	
127 	/** the main Gtk struct as a void* */
128 	protected void* getStruct()
129 	{
130 		return cast(void*)gStaticPrivate;
131 	}
132 	
133 	/**
134 	 * Sets our main struct and passes it to the parent class
135 	 */
136 	public this (GStaticPrivate* gStaticPrivate)
137 	{
138 		this.gStaticPrivate = gStaticPrivate;
139 	}
140 	
141 	/**
142 	 */
143 	
144 	/**
145 	 * Initializes private_key. Alternatively you can initialize it with
146 	 * G_STATIC_PRIVATE_INIT.
147 	 */
148 	public void init()
149 	{
150 		// void g_static_private_init (GStaticPrivate *private_key);
151 		g_static_private_init(gStaticPrivate);
152 	}
153 	
154 	/**
155 	 * Works like g_private_get() only for a GStaticPrivate.
156 	 * This function works even if g_thread_init() has not yet been called.
157 	 * Returns: the corresponding pointer.
158 	 */
159 	public void* get()
160 	{
161 		// gpointer g_static_private_get (GStaticPrivate *private_key);
162 		return g_static_private_get(gStaticPrivate);
163 	}
164 	
165 	/**
166 	 * Sets the pointer keyed to private_key for the current thread and
167 	 * the function notify to be called with that pointer (NULL or
168 	 * non-NULL), whenever the pointer is set again or whenever the
169 	 * current thread ends.
170 	 * This function works even if g_thread_init() has not yet been called.
171 	 * If g_thread_init() is called later, the data keyed to private_key
172 	 * will be inherited only by the main thread, i.e. the one that called
173 	 * g_thread_init().
174 	 * Note
175 	 * notify is used quite differently from destructor in
176 	 * g_private_new().
177 	 * Params:
178 	 * data = the new pointer.
179 	 * notify = a function to be called with the pointer whenever the
180 	 * current thread ends or sets this pointer again.
181 	 */
182 	public void set(void* data, GDestroyNotify notify)
183 	{
184 		// void g_static_private_set (GStaticPrivate *private_key,  gpointer data,  GDestroyNotify notify);
185 		g_static_private_set(gStaticPrivate, data, notify);
186 	}
187 	
188 	/**
189 	 * Releases all resources allocated to private_key.
190 	 * You don't have to call this functions for a GStaticPrivate with an
191 	 * unbounded lifetime, i.e. objects declared 'static', but if you have
192 	 * a GStaticPrivate as a member of a structure and the structure is
193 	 * freed, you should also free the GStaticPrivate.
194 	 */
195 	public void free()
196 	{
197 		// void g_static_private_free (GStaticPrivate *private_key);
198 		g_static_private_free(gStaticPrivate);
199 	}
200 }