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