Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Coalesce readable & writable into
ready
event
Having separate readable & writable events makes cleanly closing the socket and freeing up resources a bit tricky. Instead, a single `ready` event is used. The guarantees are that the event will be invoked only a single time per socket per event loop tick. Fixes #184
- Loading branch information
1 parent
f4fcc75
commit 2d80519
Showing
15 changed files
with
229 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
use {EventLoop, ReadHint, Token}; | ||
use {EventLoop, Interest, Token}; | ||
|
||
#[allow(unused_variables)] | ||
pub trait Handler { | ||
type Timeout; | ||
type Message: Send; | ||
|
||
fn readable(&mut self, event_loop: &mut EventLoop<Self>, token: Token, hint: ReadHint) { | ||
} | ||
|
||
fn writable(&mut self, event_loop: &mut EventLoop<Self>, token: Token) { | ||
/// Invoked when the socket represented by `token` is ready to be operated | ||
/// on. `events` indicates the specific operations that are | ||
/// ready to be performed. | ||
/// | ||
/// For example, when a TCP socket is ready to be read from, `events` will | ||
/// have `readable` set. When the socket is ready to be written to, | ||
/// `events` will have `writable` set. | ||
/// | ||
/// This function will only be invoked a single time per socket per event | ||
/// loop tick. | ||
fn ready(&mut self, event_loop: &mut EventLoop<Self>, token: Token, events: Interest) { | ||
} | ||
|
||
/// Invoked when a message has been received via the event loop's channel. | ||
fn notify(&mut self, event_loop: &mut EventLoop<Self>, msg: Self::Message) { | ||
} | ||
|
||
/// Invoked when a timeout has completed. | ||
fn timeout(&mut self, event_loop: &mut EventLoop<Self>, timeout: Self::Timeout) { | ||
} | ||
|
||
/// Invoked when `EventLoop` has been interrupted by a signal interrupt. | ||
fn interrupted(&mut self, event_loop: &mut EventLoop<Self>) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.