Pulls the first packet out of this FIFO, blocking until such a packet is available. Returns NULL if this FIFO has been closed or flushed.
| 1267 | // Pulls the first packet out of this FIFO, blocking until such a packet is available. |
| 1268 | // Returns NULL if this FIFO has been closed or flushed. |
| 1269 | hb_buffer_t * hb_fifo_get_wait( hb_fifo_t * f ) |
| 1270 | { |
| 1271 | hb_buffer_t * b; |
| 1272 | |
| 1273 | hb_lock( f->lock ); |
| 1274 | if( f->size < 1 ) |
| 1275 | { |
| 1276 | f->wait_empty = 1; |
| 1277 | hb_cond_timedwait( f->cond_empty, f->lock, FIFO_TIMEOUT ); |
| 1278 | if( f->size < 1 ) |
| 1279 | { |
| 1280 | hb_unlock( f->lock ); |
| 1281 | return NULL; |
| 1282 | } |
| 1283 | } |
| 1284 | b = f->first; |
| 1285 | f->first = b->next; |
| 1286 | b->next = NULL; |
| 1287 | f->size -= 1; |
| 1288 | if( f->wait_full && f->size == f->capacity - f->thresh ) |
| 1289 | { |
| 1290 | f->wait_full = 0; |
| 1291 | hb_cond_signal( f->cond_full ); |
| 1292 | } |
| 1293 | hb_unlock( f->lock ); |
| 1294 | |
| 1295 | return b; |
| 1296 | } |
| 1297 | |
| 1298 | // Pulls a packet out of this FIFO, or returns NULL if no packet is available. |
| 1299 | hb_buffer_t * hb_fifo_get( hb_fifo_t * f ) |
no test coverage detected