Skip to content

Commit

Permalink
Prevent the busy loop of async schedulers
Browse files Browse the repository at this point in the history
Simplify the implementation of an internal ` notify_write_op_ch_is_ready` method.
  • Loading branch information
tatsuya6502 authored Apr 11, 2024
1 parent dc960af commit 8805940
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/future/base_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1415,10 +1415,7 @@ where
/// Notifies all the async tasks waiting in `BaseCache::schedule_write_op` method
/// for the write op channel to have enough room.
fn notify_write_op_ch_is_ready(&self) {
let listeners = self.write_op_ch_ready_event.total_listeners();
// NOTE: The `notify` method accepts 0, so no need to check if `listeners` is
// greater than 0.
self.write_op_ch_ready_event.notify(listeners);
self.write_op_ch_ready_event.notify(usize::MAX);
}

fn now(&self) -> Instant {
Expand Down

0 comments on commit 8805940

Please sign in to comment.