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 gstreamer.AtomicQueue;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gstreamerc.gstreamer;
30 public  import gstreamerc.gstreamertypes;
31 private import gtkd.Loader;
32 
33 
34 /**
35  * The #GstAtomicQueue object implements a queue that can be used from multiple
36  * threads without performing any blocking operations.
37  */
38 public class AtomicQueue
39 {
40 	/** the main Gtk struct */
41 	protected GstAtomicQueue* gstAtomicQueue;
42 	protected bool ownedRef;
43 
44 	/** Get the main Gtk struct */
45 	public GstAtomicQueue* getAtomicQueueStruct(bool transferOwnership = false)
46 	{
47 		if (transferOwnership)
48 			ownedRef = false;
49 		return gstAtomicQueue;
50 	}
51 
52 	/** the main Gtk struct as a void* */
53 	protected void* getStruct()
54 	{
55 		return cast(void*)gstAtomicQueue;
56 	}
57 
58 	/**
59 	 * Sets our main struct and passes it to the parent class.
60 	 */
61 	public this (GstAtomicQueue* gstAtomicQueue, bool ownedRef = false)
62 	{
63 		this.gstAtomicQueue = gstAtomicQueue;
64 		this.ownedRef = ownedRef;
65 	}
66 
67 	~this ()
68 	{
69 		if (  Linker.isLoaded(LIBRARY_GSTREAMER) && ownedRef )
70 			gst_atomic_queue_unref(gstAtomicQueue);
71 	}
72 
73 
74 	/** */
75 	public static GType getType()
76 	{
77 		return gst_atomic_queue_get_type();
78 	}
79 
80 	/**
81 	 * Create a new atomic queue instance. @initial_size will be rounded up to the
82 	 * nearest power of 2 and used as the initial size of the queue.
83 	 *
84 	 * Params:
85 	 *     initialSize = initial queue size
86 	 *
87 	 * Returns: a new #GstAtomicQueue
88 	 *
89 	 * Throws: ConstructionException GTK+ fails to create the object.
90 	 */
91 	public this(uint initialSize)
92 	{
93 		auto p = gst_atomic_queue_new(initialSize);
94 		
95 		if(p is null)
96 		{
97 			throw new ConstructionException("null returned by new");
98 		}
99 		
100 		this(cast(GstAtomicQueue*) p);
101 	}
102 
103 	/**
104 	 * Get the amount of items in the queue.
105 	 *
106 	 * Returns: the number of elements in the queue.
107 	 */
108 	public uint length()
109 	{
110 		return gst_atomic_queue_length(gstAtomicQueue);
111 	}
112 
113 	/**
114 	 * Peek the head element of the queue without removing it from the queue.
115 	 *
116 	 * Returns: the head element of @queue or
117 	 *     %NULL when the queue is empty.
118 	 */
119 	public void* peek()
120 	{
121 		return gst_atomic_queue_peek(gstAtomicQueue);
122 	}
123 
124 	/**
125 	 * Get the head element of the queue.
126 	 *
127 	 * Returns: the head element of @queue or %NULL when
128 	 *     the queue is empty.
129 	 */
130 	public void* pop()
131 	{
132 		return gst_atomic_queue_pop(gstAtomicQueue);
133 	}
134 
135 	/**
136 	 * Append @data to the tail of the queue.
137 	 *
138 	 * Params:
139 	 *     data = the data
140 	 */
141 	public void push(void* data)
142 	{
143 		gst_atomic_queue_push(gstAtomicQueue, data);
144 	}
145 
146 	/**
147 	 * Increase the refcount of @queue.
148 	 */
149 	public void doref()
150 	{
151 		gst_atomic_queue_ref(gstAtomicQueue);
152 	}
153 
154 	/**
155 	 * Unref @queue and free the memory when the refcount reaches 0.
156 	 */
157 	public void unref()
158 	{
159 		gst_atomic_queue_unref(gstAtomicQueue);
160 	}
161 }