aboutsummaryrefslogtreecommitdiff
path: root/src/itoqueue.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/itoqueue.h')
-rw-r--r--src/itoqueue.h61
1 files changed, 32 insertions, 29 deletions
diff --git a/src/itoqueue.h b/src/itoqueue.h
index 5945344..1a4e0b6 100644
--- a/src/itoqueue.h
+++ b/src/itoqueue.h
@@ -16,6 +16,7 @@ namespace Bu
16 * something is enqueued within the specified time limit, or NULL if the 16 * something is enqueued within the specified time limit, or NULL if the
17 * time limit is exceded. 17 * time limit is exceded.
18 *@author Mike Buland 18 *@author Mike Buland
19 *@ingroup Threading Containers
19 */ 20 */
20 template <class T> 21 template <class T>
21 class ItoQueue 22 class ItoQueue
@@ -59,11 +60,11 @@ namespace Bu
59 } 60 }
60 61
61 /** 62 /**
62 * Enqueue a pieces of data. The new data will go at the end of the queue, 63 * Enqueue a pieces of data. The new data will go at the end of the
63 * and unless another piece of data is enqueued, will be the last piece of 64 * queue, and unless another piece of data is enqueued, will be the
64 * data to be dequeued. 65 * last piece of data to be dequeued.
65 *@param pData The data to enqueue. If this is not a primitive data type 66 *@param pData The data to enqueue. If this is not a primitive data
66 * it's probably best to use a pointer type. 67 * type it's probably best to use a pointer type.
67 */ 68 */
68 void enqueue( T pData ) 69 void enqueue( T pData )
69 { 70 {
@@ -91,20 +92,22 @@ namespace Bu
91 } 92 }
92 93
93 /** 94 /**
94 * Dequeue the first item from the queue. This function can operate in two 95 * Dequeue the first item from the queue. This function can operate in
95 * different modes, blocking and non-blocking. In non-blocking mode it will 96 * two different modes, blocking and non-blocking. In non-blocking
96 * return immediately weather there was data in the queue or not. If there 97 * mode it will return immediately weather there was data in the queue
97 * was data it will remove it from the queue and return it to the caller. 98 * or not. If there was data it will remove it from the queue and
98 * In blocking mode it will block forever wating for data to be enqueued. 99 * return it to the caller.
99 * When data finally is enqueued this function will return immediately with 100 *
100 * the new data. The only way this function should ever return a null in 101 * In blocking mode it will block forever wating for data to be
101 * blocking mode is if the calling thread was cancelled. It's probably a 102 * enqueued. When data finally is enqueued this function will return
102 * good idea to check for NULL return values even if you use blocking, just 103 * immediately with the new data. The only way this function should
103 * to be on the safe side. 104 * ever return a null in blocking mode is if the calling thread was
104 *@param bBlock Set to true to enable blocking, leave as false to work in 105 * cancelled. It's probably a good idea to check for NULL return
105 * non-blocking mode. 106 * values even if you use blocking, just to be on the safe side.
106 *@returns The next piece of data in the queue, or NULL if no data was in 107 *@param bBlock Set to true to enable blocking, leave as false to work
107 * the queue. 108 * in non-blocking mode.
109 *@returns The next piece of data in the queue, or NULL if no data was
110 * in the queue.
108 */ 111 */
109 T dequeue( bool bBlock=false ) 112 T dequeue( bool bBlock=false )
110 { 113 {
@@ -143,15 +146,15 @@ namespace Bu
143 } 146 }
144 147
145 /** 148 /**
146 * Operates just like the other dequeue function in blocking mode with one 149 * Operates just like the other dequeue function in blocking mode with
147 * twist. This function will block for at most nSec seconds and nUSec 150 * one twist. This function will block for at most nSec seconds and
148 * micro-seconds. If the timer is up and no data is available, this will 151 * nUSec micro-seconds. If the timer is up and no data is available,
149 * just return NULL. If data is enqueued before the timeout expires, it 152 * this will just return NULL. If data is enqueued before the timeout
150 * will dequeue and exit immediately. 153 * expires, it will dequeue and exit immediately.
151 *@param nSec The number of seconds to wait, max. 154 *@param nSec The number of seconds to wait, max.
152 *@param nUSec The number of micro-seconds to wait, max. 155 *@param nUSec The number of micro-seconds to wait, max.
153 *@returns The next piece of data in the queue, or NULL if the timeout was 156 *@returns The next piece of data in the queue, or NULL if the timeout
154 * exceeded. 157 * was exceeded.
155 */ 158 */
156 T dequeue( int nSec, int nUSec ) 159 T dequeue( int nSec, int nUSec )
157 { 160 {
@@ -195,9 +198,9 @@ namespace Bu
195 } 198 }
196 199
197 /** 200 /**
198 * Checks to see if the queue has data in it or not. Note that there is no 201 * Checks to see if the queue has data in it or not. Note that there
199 * function to determine the length of the queue. This data isn't kept 202 * is no function to determine the length of the queue. This data
200 * track of. If you really need to know, fix this. 203 * isn't kept track of. If you really need to know, fix this.
201 *@returns True if the queue is empty, false if it has data in it. 204 *@returns True if the queue is empty, false if it has data in it.
202 */ 205 */
203 bool isEmpty() 206 bool isEmpty()