This will block until there is something in the queue
| 91 | |
| 92 | // This will block until there is something in the queue |
| 93 | void GenericQ::get(void **item, bool nonBlocking) |
| 94 | { |
| 95 | if(deadYet) return; |
| 96 | if(item == NULL) THROW("NULL argument in GenericQ::get()"); |
| 97 | if(nonBlocking) |
| 98 | { |
| 99 | if(!hasItem.tryWait()) |
| 100 | { |
| 101 | *item = NULL; return; |
| 102 | } |
| 103 | } |
| 104 | else hasItem.wait(); |
| 105 | if(!deadYet) |
| 106 | { |
| 107 | CriticalSection::SafeLock l(mutex); |
| 108 | if(deadYet) return; |
| 109 | if(start == NULL) THROW("Nothing in the queue"); |
| 110 | *item = start->item; |
| 111 | Entry *temp = start->next; |
| 112 | delete start; start = temp; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | |
| 117 | int GenericQ::items(void) |