| 607 | } |
| 608 | |
| 609 | void pipe_free(pipe_t* p) |
| 610 | { |
| 611 | size_t new_producer_refcount, |
| 612 | new_consumer_refcount; |
| 613 | |
| 614 | mutex_lock(&p->begin_lock); |
| 615 | assertume(p->producer_refcount > 0); |
| 616 | new_producer_refcount = --p->producer_refcount; |
| 617 | mutex_unlock(&p->begin_lock); |
| 618 | |
| 619 | mutex_lock(&p->end_lock); |
| 620 | assertume(p->consumer_refcount > 0); |
| 621 | new_consumer_refcount = --p->consumer_refcount; |
| 622 | mutex_unlock(&p->end_lock); |
| 623 | |
| 624 | if(unlikely(new_consumer_refcount == 0)) |
| 625 | { |
| 626 | p->buffer = (free(p->buffer), NULL); |
| 627 | |
| 628 | if(likely(new_producer_refcount > 0)) |
| 629 | cond_broadcast(&p->just_popped); |
| 630 | else |
| 631 | deallocate(p); |
| 632 | } |
| 633 | else if(unlikely(new_producer_refcount == 0)) |
| 634 | cond_broadcast(&p->just_pushed); |
| 635 | } |
| 636 | |
| 637 | void pipe_producer_free(pipe_producer_t* handle) |
| 638 | { |
nothing calls this directly
no test coverage detected