+int hb_fifo_full_wait( hb_fifo_t * f )
+{
+ int result;
+
+ hb_lock( f->lock );
+ if( f->size >= f->capacity )
+ {
+ f->wait_full = 1;
+ hb_cond_timedwait( f->cond_full, f->lock, FIFO_TIMEOUT );
+ }
+ result = ( f->size < f->capacity );
+ hb_unlock( f->lock );
+ return result;
+}
+
+void hb_fifo_push_wait( hb_fifo_t * f, hb_buffer_t * b )
+{
+ if( !b )
+ {
+ return;
+ }
+
+ hb_lock( f->lock );
+ if( f->size >= f->capacity )
+ {
+ f->wait_full = 1;
+ hb_cond_timedwait( f->cond_full, f->lock, FIFO_TIMEOUT );
+ }
+ if( f->size > 0 )
+ {
+ f->last->next = b;
+ }
+ else
+ {
+ f->first = b;
+ }
+ f->last = b;
+ f->size += 1;
+ while( f->last->next )
+ {
+ f->size += 1;
+ f->last = f->last->next;
+ }
+ if( f->wait_empty && f->size >= f->thresh )
+ {
+ f->wait_empty = 0;
+ hb_cond_signal( f->cond_empty );
+ }
+ hb_unlock( f->lock );
+}
+