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 
63 private import glib.ErrorG;
64 private import glib.GException;
65 
66 
67 
68 private import gstreamer.ObjectGst;
69 
70 /**
71  * This object provides an abstraction for creating threads. The default
72  * implementation uses a regular GThreadPool to start tasks.
73  *
74  * Subclasses can be made to create custom threads.
75  *
76  * Last reviewed on 2009-04-23 (0.10.24)
77  */
78 public class TaskPool : ObjectGst
79 {
80 	
81 	/** the main Gtk struct */
82 	protected GstTaskPool* gstTaskPool;
83 	
84 	
85 	public GstTaskPool* getTaskPoolStruct()
86 	{
87 		return gstTaskPool;
88 	}
89 	
90 	
91 	/** the main Gtk struct as a void* */
92 	protected override void* getStruct()
93 	{
94 		return cast(void*)gstTaskPool;
95 	}
96 	
97 	/**
98 	 * Sets our main struct and passes it to the parent class
99 	 */
100 	public this (GstTaskPool* gstTaskPool)
101 	{
102 		super(cast(GstObject*)gstTaskPool);
103 		this.gstTaskPool = gstTaskPool;
104 	}
105 	
106 	protected override void setStruct(GObject* obj)
107 	{
108 		super.setStruct(obj);
109 		gstTaskPool = cast(GstTaskPool*)obj;
110 	}
111 	
112 	/**
113 	 */
114 	
115 	/**
116 	 * Create a new default task pool. The default task pool will use a regular
117 	 * GThreadPool for threads.
118 	 * Throws: ConstructionException GTK+ fails to create the object.
119 	 */
120 	public this ()
121 	{
122 		// GstTaskPool * gst_task_pool_new (void);
123 		auto p = gst_task_pool_new();
124 		if(p is null)
125 		{
126 			throw new ConstructionException("null returned by gst_task_pool_new()");
127 		}
128 		this(cast(GstTaskPool*) p);
129 	}
130 	
131 	/**
132 	 * Prepare the taskpool for accepting gst_task_pool_push() operations.
133 	 * MT safe.
134 	 * Throws: GException on failure.
135 	 */
136 	public void prepare()
137 	{
138 		// void gst_task_pool_prepare (GstTaskPool *pool,  GError **error);
139 		GError* err = null;
140 		
141 		gst_task_pool_prepare(gstTaskPool, &err);
142 		
143 		if (err !is null)
144 		{
145 			throw new GException( new ErrorG(err) );
146 		}
147 		
148 	}
149 	
150 	/**
151 	 * Start the execution of a new thread from pool.
152 	 * Params:
153 	 * func = the function to call. [scope async]
154 	 * userData = data to pass to func. [closure]
155 	 * 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]
156 	 * Throws: GException on failure.
157 	 */
158 	public void* push(GstTaskPoolFunction func, void* userData)
159 	{
160 		// gpointer gst_task_pool_push (GstTaskPool *pool,  GstTaskPoolFunction func,  gpointer user_data,  GError **error);
161 		GError* err = null;
162 		
163 		auto p = gst_task_pool_push(gstTaskPool, func, userData, &err);
164 		
165 		if (err !is null)
166 		{
167 			throw new GException( new ErrorG(err) );
168 		}
169 		
170 		return p;
171 	}
172 	
173 	/**
174 	 * Join a task and/or return it to the pool. id is the id obtained from
175 	 * gst_task_pool_push().
176 	 * Params:
177 	 * id = the id
178 	 */
179 	public void join(void* id)
180 	{
181 		// void gst_task_pool_join (GstTaskPool *pool,  gpointer id);
182 		gst_task_pool_join(gstTaskPool, id);
183 	}
184 	
185 	/**
186 	 * Wait for all tasks to be stopped. This is mainly used internally
187 	 * to ensure proper cleanup of internal data structures in test suites.
188 	 * MT safe.
189 	 */
190 	public void cleanup()
191 	{
192 		// void gst_task_pool_cleanup (GstTaskPool *pool);
193 		gst_task_pool_cleanup(gstTaskPool);
194 	}
195 }