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