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 module gio.IOSchedulerJob;
26 
27 private import gio.Cancellable;
28 private import gio.c.functions;
29 public  import gio.c.types;
30 public  import gtkc.giotypes;
31 
32 
33 /**
34  * Opaque class for defining and scheduling IO jobs.
35  */
36 public class IOSchedulerJob
37 {
38 	/** the main Gtk struct */
39 	protected GIOSchedulerJob* gIOSchedulerJob;
40 	protected bool ownedRef;
41 
42 	/** Get the main Gtk struct */
43 	public GIOSchedulerJob* getIOSchedulerJobStruct(bool transferOwnership = false)
44 	{
45 		if (transferOwnership)
46 			ownedRef = false;
47 		return gIOSchedulerJob;
48 	}
49 
50 	/** the main Gtk struct as a void* */
51 	protected void* getStruct()
52 	{
53 		return cast(void*)gIOSchedulerJob;
54 	}
55 
56 	/**
57 	 * Sets our main struct and passes it to the parent class.
58 	 */
59 	public this (GIOSchedulerJob* gIOSchedulerJob, bool ownedRef = false)
60 	{
61 		this.gIOSchedulerJob = gIOSchedulerJob;
62 		this.ownedRef = ownedRef;
63 	}
64 
65 
66 	/**
67 	 * Used from an I/O job to send a callback to be run in the thread
68 	 * that the job was started from, waiting for the result (and thus
69 	 * blocking the I/O job).
70 	 *
71 	 * Deprecated: Use g_main_context_invoke().
72 	 *
73 	 * Params:
74 	 *     func = a #GSourceFunc callback that will be called in the original thread
75 	 *     userData = data to pass to @func
76 	 *     notify = a #GDestroyNotify for @user_data, or %NULL
77 	 *
78 	 * Returns: The return value of @func
79 	 */
80 	public bool sendToMainloop(GSourceFunc func, void* userData, GDestroyNotify notify)
81 	{
82 		return g_io_scheduler_job_send_to_mainloop(gIOSchedulerJob, func, userData, notify) != 0;
83 	}
84 
85 	/**
86 	 * Used from an I/O job to send a callback to be run asynchronously in
87 	 * the thread that the job was started from. The callback will be run
88 	 * when the main loop is available, but at that time the I/O job might
89 	 * have finished. The return value from the callback is ignored.
90 	 *
91 	 * Note that if you are passing the @user_data from g_io_scheduler_push_job()
92 	 * on to this function you have to ensure that it is not freed before
93 	 * @func is called, either by passing %NULL as @notify to
94 	 * g_io_scheduler_push_job() or by using refcounting for @user_data.
95 	 *
96 	 * Deprecated: Use g_main_context_invoke().
97 	 *
98 	 * Params:
99 	 *     func = a #GSourceFunc callback that will be called in the original thread
100 	 *     userData = data to pass to @func
101 	 *     notify = a #GDestroyNotify for @user_data, or %NULL
102 	 */
103 	public void sendToMainloopAsync(GSourceFunc func, void* userData, GDestroyNotify notify)
104 	{
105 		g_io_scheduler_job_send_to_mainloop_async(gIOSchedulerJob, func, userData, notify);
106 	}
107 
108 	/**
109 	 * Cancels all cancellable I/O jobs.
110 	 *
111 	 * A job is cancellable if a #GCancellable was passed into
112 	 * g_io_scheduler_push_job().
113 	 *
114 	 * Deprecated: You should never call this function, since you don't
115 	 * know how other libraries in your program might be making use of
116 	 * gioscheduler.
117 	 */
118 	public static void cancelAllJobs()
119 	{
120 		g_io_scheduler_cancel_all_jobs();
121 	}
122 
123 	/**
124 	 * Schedules the I/O job to run in another thread.
125 	 *
126 	 * @notify will be called on @user_data after @job_func has returned,
127 	 * regardless whether the job was cancelled or has run to completion.
128 	 *
129 	 * If @cancellable is not %NULL, it can be used to cancel the I/O job
130 	 * by calling g_cancellable_cancel() or by calling
131 	 * g_io_scheduler_cancel_all_jobs().
132 	 *
133 	 * Deprecated: use #GThreadPool or g_task_run_in_thread()
134 	 *
135 	 * Params:
136 	 *     jobFunc = a #GIOSchedulerJobFunc.
137 	 *     userData = data to pass to @job_func
138 	 *     notify = a #GDestroyNotify for @user_data, or %NULL
139 	 *     ioPriority = the [I/O priority][io-priority]
140 	 *         of the request.
141 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
142 	 */
143 	public static void pushJob(GIOSchedulerJobFunc jobFunc, void* userData, GDestroyNotify notify, int ioPriority, Cancellable cancellable)
144 	{
145 		g_io_scheduler_push_job(jobFunc, userData, notify, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct());
146 	}
147 }