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  = GstTaskPool.html
27  * outPack = gstreamer
28  * outFile = TaskPool
29  * strct   = GstTaskPool
30  * realStrct=
31  * ctorStrct=
32  * clss    = TaskPool
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gst_task_pool_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.ErrorG
47  * 	- glib.GException
48  * structWrap:
49  * module aliases:
50  * local aliases:
51  * overrides:
52  */
53 
54 module gstreamer.TaskPool;
55 
56 public  import gstreamerc.gstreamertypes;
57 
58 private import gstreamerc.gstreamer;
59 private import glib.ConstructionException;
60 private import gobject.ObjectG;
61 
62 private import glib.ErrorG;
63 private import glib.GException;
64 
65 
66 private import gstreamer.ObjectGst;
67 
68 /**
69  * This object provides an abstraction for creating threads. The default
70  * implementation uses a regular GThreadPool to start tasks.
71  *
72  * Subclasses can be made to create custom threads.
73  *
74  * Last reviewed on 2009-04-23 (0.10.24)
75  */
76 public class TaskPool : ObjectGst
77 {
78 	
79 	/** the main Gtk struct */
80 	protected GstTaskPool* gstTaskPool;
81 	
82 	
83 	/** Get the main Gtk struct */
84 	public GstTaskPool* getTaskPoolStruct()
85 	{
86 		return gstTaskPool;
87 	}
88 	
89 	
90 	/** the main Gtk struct as a void* */
91 	protected override void* getStruct()
92 	{
93 		return cast(void*)gstTaskPool;
94 	}
95 	
96 	/**
97 	 * Sets our main struct and passes it to the parent class
98 	 */
99 	public this (GstTaskPool* gstTaskPool)
100 	{
101 		super(cast(GstObject*)gstTaskPool);
102 		this.gstTaskPool = gstTaskPool;
103 	}
104 	
105 	protected override void setStruct(GObject* obj)
106 	{
107 		super.setStruct(obj);
108 		gstTaskPool = cast(GstTaskPool*)obj;
109 	}
110 	
111 	/**
112 	 */
113 	
114 	/**
115 	 * Create a new default task pool. The default task pool will use a regular
116 	 * GThreadPool for threads.
117 	 * Throws: ConstructionException GTK+ fails to create the object.
118 	 */
119 	public this ()
120 	{
121 		// GstTaskPool * gst_task_pool_new (void);
122 		auto p = gst_task_pool_new();
123 		if(p is null)
124 		{
125 			throw new ConstructionException("null returned by gst_task_pool_new()");
126 		}
127 		this(cast(GstTaskPool*) p);
128 	}
129 	
130 	/**
131 	 * Prepare the taskpool for accepting gst_task_pool_push() operations.
132 	 * MT safe.
133 	 * Throws: GException on failure.
134 	 */
135 	public void prepare()
136 	{
137 		// void gst_task_pool_prepare (GstTaskPool *pool,  GError **error);
138 		GError* err = null;
139 		
140 		gst_task_pool_prepare(gstTaskPool, &err);
141 		
142 		if (err !is null)
143 		{
144 			throw new GException( new ErrorG(err) );
145 		}
146 		
147 	}
148 	
149 	/**
150 	 * Start the execution of a new thread from pool.
151 	 * Params:
152 	 * func = the function to call. [scope async]
153 	 * userData = data to pass to func. [closure]
154 	 * Returns: a pointer that should be used for the gst_task_pool_join function. This pointer can be NULL, you must check error to detect errors. [transfer none]
155 	 * Throws: GException on failure.
156 	 */
157 	public void* push(GstTaskPoolFunction func, void* userData)
158 	{
159 		// gpointer gst_task_pool_push (GstTaskPool *pool,  GstTaskPoolFunction func,  gpointer user_data,  GError **error);
160 		GError* err = null;
161 		
162 		auto p = gst_task_pool_push(gstTaskPool, func, userData, &err);
163 		
164 		if (err !is null)
165 		{
166 			throw new GException( new ErrorG(err) );
167 		}
168 		
169 		return p;
170 	}
171 	
172 	/**
173 	 * Join a task and/or return it to the pool. id is the id obtained from
174 	 * gst_task_pool_push().
175 	 * Params:
176 	 * id = the id
177 	 */
178 	public void join(void* id)
179 	{
180 		// void gst_task_pool_join (GstTaskPool *pool,  gpointer id);
181 		gst_task_pool_join(gstTaskPool, id);
182 	}
183 	
184 	/**
185 	 * Wait for all tasks to be stopped. This is mainly used internally
186 	 * to ensure proper cleanup of internal data structures in test suites.
187 	 * MT safe.
188 	 */
189 	public void cleanup()
190 	{
191 		// void gst_task_pool_cleanup (GstTaskPool *pool);
192 		gst_task_pool_cleanup(gstTaskPool);
193 	}
194 }