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