MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / pipe_free

Function pipe_free

src/utils/bluetooth/macos_third_party/pipe.c:609–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

607}
608
609void 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
637void pipe_producer_free(pipe_producer_t* handle)
638{

Callers

nothing calls this directly

Calls 2

cond_broadcastFunction · 0.85
deallocateFunction · 0.85

Tested by

no test coverage detected