mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -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;
|
Mutex.unlock self.mutex;
|
||||||
raise Closed
|
raise Closed
|
||||||
) else (
|
) else (
|
||||||
|
let was_empty = Queue.is_empty self.q in
|
||||||
Queue.push x self.q;
|
Queue.push x self.q;
|
||||||
Condition.signal self.cond;
|
if was_empty then Condition.broadcast self.cond;
|
||||||
Mutex.unlock self.mutex
|
Mutex.unlock self.mutex
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -79,8 +80,9 @@ let try_push (self : _ t) x : bool =
|
||||||
raise Closed
|
raise Closed
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let was_empty = Queue.is_empty self.q in
|
||||||
Queue.push x self.q;
|
Queue.push x self.q;
|
||||||
Condition.signal self.cond;
|
if was_empty then Condition.broadcast self.cond;
|
||||||
Mutex.unlock self.mutex;
|
Mutex.unlock self.mutex;
|
||||||
true
|
true
|
||||||
) else
|
) else
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue