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  = gdk3-Threads.html
27  * outPack = gdk
28  * outFile = Threads
29  * strct   = 
30  * realStrct=
31  * ctorStrct=
32  * clss    = 
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gdk_
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 gdk.Threads;
53 
54 public  import gtkc.gdktypes;
55 
56 private import gtkc.gdk;
57 private import glib.ConstructionException;
58 private import gobject.ObjectG;
59 
60 
61 
62 
63 
64 
65 /**
66  */
67 
68 /**
69  * Warning
70  * gdk_threads_init has been deprecated since version 3.6 and should not be used in newly-written code. All GDK and GTK+ calls should be made from the main
71  *  thread
72  * Initializes GDK so that it can be used from multiple threads
73  * in conjunction with gdk_threads_enter() and gdk_threads_leave().
74  * This call must be made before any use of the main loop from
75  * GTK+; to be safe, call it before gtk_init().
76  */
77 public static void threadsInit()
78 {
79 	// void gdk_threads_init (void);
80 	gdk_threads_init();
81 }
82 
83 /**
84  * Warning
85  * gdk_threads_enter has been deprecated since version 3.6 and should not be used in newly-written code. All GDK and GTK+ calls should be made from the main
86  *  thread
87  * This function marks the beginning of a critical section in which
88  * GDK and GTK+ functions can be called safely and without causing race
89  * conditions. Only one thread at a time can be in such a critial
90  * section.
91  */
92 public static void threadsEnter()
93 {
94 	// void gdk_threads_enter (void);
95 	gdk_threads_enter();
96 }
97 
98 /**
99  * Warning
100  * gdk_threads_leave has been deprecated since version 3.6 and should not be used in newly-written code. All GDK and GTK+ calls should be made from the main
101  *  thread
102  * Leaves a critical region begun with gdk_threads_enter().
103  */
104 public static void threadsLeave()
105 {
106 	// void gdk_threads_leave (void);
107 	gdk_threads_leave();
108 }
109 
110 /**
111  * Warning
112  * gdk_threads_set_lock_functions has been deprecated since version 3.6 and should not be used in newly-written code. All GDK and GTK+ calls should be made from the main
113  *  thread
114  * Allows the application to replace the standard method that
115  * GDK uses to protect its data structures. Normally, GDK
116  * creates a single GMutex that is locked by gdk_threads_enter(),
117  * and released by gdk_threads_leave(); using this function an
118  * application provides, instead, a function enter_fn that is
119  * called by gdk_threads_enter() and a function leave_fn that is
120  * called by gdk_threads_leave().
121  * The functions must provide at least same locking functionality
122  * as the default implementation, but can also do extra application
123  * specific processing.
124  * As an example, consider an application that has its own recursive
125  * lock that when held, holds the GTK+ lock as well. When GTK+ unlocks
126  * the GTK+ lock when entering a recursive main loop, the application
127  * must temporarily release its lock as well.
128  * Most threaded GTK+ apps won't need to use this method.
129  * This method must be called before gdk_threads_init(), and cannot
130  * be called multiple times.
131  * Since 2.4
132  * Params:
133  * enterFn = function called to guard GDK
134  * leaveFn = function called to release the guard
135  */
136 public static void threadsSetLockFunctions(GCallback enterFn, GCallback leaveFn)
137 {
138 	// void gdk_threads_set_lock_functions (GCallback enter_fn,  GCallback leave_fn);
139 	gdk_threads_set_lock_functions(enterFn, leaveFn);
140 }
141 
142 /**
143  * A wrapper for the common usage of gdk_threads_add_idle_full()
144  * assigning the default priority, G_PRIORITY_DEFAULT_IDLE.
145  * See gdk_threads_add_idle_full().
146  * Since 2.12
147  * Params:
148  * data = data to pass to function
149  * Returns: the ID (greater than 0) of the event source.
150  */
151 public static uint threadsAddIdle(GSourceFunc funct, void* data)
152 {
153 	// guint gdk_threads_add_idle (GSourceFunc function,  gpointer data);
154 	return gdk_threads_add_idle(funct, data);
155 }
156 
157 /**
158  * Adds a function to be called whenever there are no higher priority
159  * events pending. If the function returns FALSE it is automatically
160  * removed from the list of event sources and will not be called again.
161  * This variant of g_idle_add_full() calls function with the GDK lock
162  * held. It can be thought of a MT-safe version for GTK+ widgets for the
163  * following use case, where you have to worry about idle_callback()
164  * running in thread A and accessing self after it has been finalized
165  * Since 2.12
166  * Params:
167  * priority = the priority of the idle source. Typically this will be in the
168  * range between G_PRIORITY_DEFAULT_IDLE and G_PRIORITY_HIGH_IDLE
169  * data = data to pass to function
170  * notify = function to call when the idle is removed, or NULL. [allow-none]
171  * Returns: the ID (greater than 0) of the event source.
172  */
173 public static uint threadsAddIdleFull(int priority, GSourceFunc funct, void* data, GDestroyNotify notify)
174 {
175 	// guint gdk_threads_add_idle_full (gint priority,  GSourceFunc function,  gpointer data,  GDestroyNotify notify);
176 	return gdk_threads_add_idle_full(priority, funct, data, notify);
177 }
178 
179 /**
180  * A wrapper for the common usage of gdk_threads_add_timeout_full()
181  * assigning the default priority, G_PRIORITY_DEFAULT.
182  * See gdk_threads_add_timeout_full().
183  * Since 2.12
184  * Params:
185  * interval = the time between calls to the function, in milliseconds
186  * (1/1000ths of a second)
187  * data = data to pass to function
188  * Returns: the ID (greater than 0) of the event source.
189  */
190 public static uint threadsAddTimeout(uint interval, GSourceFunc funct, void* data)
191 {
192 	// guint gdk_threads_add_timeout (guint interval,  GSourceFunc function,  gpointer data);
193 	return gdk_threads_add_timeout(interval, funct, data);
194 }
195 
196 /**
197  * Sets a function to be called at regular intervals holding the GDK lock,
198  * with the given priority. The function is called repeatedly until it
199  * returns FALSE, at which point the timeout is automatically destroyed
200  * and the function will not be called again. The notify function is
201  * called when the timeout is destroyed. The first call to the
202  * function will be at the end of the first interval.
203  * Note that timeout functions may be delayed, due to the processing of other
204  * event sources. Thus they should not be relied on for precise timing.
205  * After each call to the timeout function, the time of the next
206  * timeout is recalculated based on the current time and the given interval
207  * (it does not try to 'catch up' time lost in delays).
208  * This variant of g_timeout_add_full() can be thought of a MT-safe version
209  * Since 2.12
210  * Params:
211  * priority = the priority of the timeout source. Typically this will be in the
212  * range between G_PRIORITY_DEFAULT_IDLE and G_PRIORITY_HIGH_IDLE.
213  * interval = the time between calls to the function, in milliseconds
214  * (1/1000ths of a second)
215  * data = data to pass to function
216  * notify = function to call when the timeout is removed, or NULL. [allow-none]
217  * Returns: the ID (greater than 0) of the event source.
218  */
219 public static uint threadsAddTimeoutFull(int priority, uint interval, GSourceFunc funct, void* data, GDestroyNotify notify)
220 {
221 	// guint gdk_threads_add_timeout_full (gint priority,  guint interval,  GSourceFunc function,  gpointer data,  GDestroyNotify notify);
222 	return gdk_threads_add_timeout_full(priority, interval, funct, data, notify);
223 }
224 
225 /**
226  * A wrapper for the common usage of gdk_threads_add_timeout_seconds_full()
227  * assigning the default priority, G_PRIORITY_DEFAULT.
228  * For details, see gdk_threads_add_timeout_full().
229  * Since 2.14
230  * Params:
231  * interval = the time between calls to the function, in seconds
232  * data = data to pass to function
233  * Returns: the ID (greater than 0) of the event source.
234  */
235 public static uint threadsAddTimeoutSeconds(uint interval, GSourceFunc funct, void* data)
236 {
237 	// guint gdk_threads_add_timeout_seconds (guint interval,  GSourceFunc function,  gpointer data);
238 	return gdk_threads_add_timeout_seconds(interval, funct, data);
239 }
240 
241 /**
242  * A variant of gdk_threads_add_timeout_full() with second-granularity.
243  * See g_timeout_add_seconds_full() for a discussion of why it is
244  * a good idea to use this function if you don't need finer granularity.
245  * Since 2.14
246  * Params:
247  * priority = the priority of the timeout source. Typically this will be in the
248  * range between G_PRIORITY_DEFAULT_IDLE and G_PRIORITY_HIGH_IDLE.
249  * interval = the time between calls to the function, in seconds
250  * data = data to pass to function
251  * notify = function to call when the timeout is removed, or NULL. [allow-none]
252  * Returns: the ID (greater than 0) of the event source.
253  */
254 public static uint threadsAddTimeoutSecondsFull(int priority, uint interval, GSourceFunc funct, void* data, GDestroyNotify notify)
255 {
256 	// guint gdk_threads_add_timeout_seconds_full  (gint priority,  guint interval,  GSourceFunc function,  gpointer data,  GDestroyNotify notify);
257 	return gdk_threads_add_timeout_seconds_full(priority, interval, funct, data, notify);
258 }
259