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