mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-05 19:00:33 -05:00
perf: in Bb_queue, only signal condition on push if queue was empty
This commit is contained in:
parent
18d5bad2a9
commit
0f670c47d3
1 changed files with 4 additions and 2 deletions
|
|
@ -29,8 +29,9 @@ let push (self : _ t) x : unit =
|
|||
Mutex.unlock self.mutex;
|
||||
raise Closed
|
||||
) else (
|
||||
let was_empty = Queue.is_empty self.q in
|
||||
Queue.push x self.q;
|
||||
Condition.signal self.cond;
|
||||
if was_empty then Condition.broadcast self.cond;
|
||||
Mutex.unlock self.mutex
|
||||
)
|
||||
|
||||
|
|
@ -79,8 +80,9 @@ let try_push (self : _ t) x : bool =
|
|||
raise Closed
|
||||
);
|
||||
|
||||
let was_empty = Queue.is_empty self.q in
|
||||
Queue.push x self.q;
|
||||
Condition.signal self.cond;
|
||||
if was_empty then Condition.broadcast self.cond;
|
||||
Mutex.unlock self.mutex;
|
||||
true
|
||||
) else
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue