Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove Socket token generic in favor of a struct
Token has become a tuple struct wrapping a single uint. Using a generic is not much use because supporting epoll and kqueue require that: a) implement Copy b) fit in the same number of bytes as uint Given these requirements, it seems easier to just use a uint based token.
- Loading branch information
1 parent
d717457
commit 49e99b3
Showing
13 changed files
with
159 additions
and
166 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,17 @@ | ||
use reactor::{Reactor}; | ||
use reactor::Reactor; | ||
use token::Token; | ||
|
||
#[allow(unused_variable)] | ||
pub trait Handler<T: Token, T2, M: Send> { | ||
fn readable(&mut self, reactor: &mut Reactor<T, T2, M>, token: T) { | ||
pub trait Handler<T, M: Send> { | ||
fn readable(&mut self, reactor: &mut Reactor<T, M>, token: Token) { | ||
} | ||
|
||
fn writable(&mut self, reactor: &mut Reactor<T, T2, M>, token: T) { | ||
fn writable(&mut self, reactor: &mut Reactor<T, M>, token: Token) { | ||
} | ||
|
||
fn notify(&mut self, reactor: &mut Reactor<T, T2, M>, msg: M) { | ||
fn notify(&mut self, reactor: &mut Reactor<T, M>, msg: M) { | ||
} | ||
|
||
fn timeout(&mut self, reactor: &mut Reactor<T, T2, M>, timeout: T2) { | ||
} | ||
} | ||
|
||
pub trait Token : Copy { | ||
fn from_u64(val: u64) -> Self; | ||
|
||
fn to_u64(self) -> u64; | ||
} | ||
|
||
impl Token for int { | ||
fn from_u64(val: u64) -> int { | ||
val as int | ||
} | ||
|
||
fn to_u64(self) -> u64 { | ||
self as u64 | ||
} | ||
} | ||
|
||
impl Token for uint { | ||
fn from_u64(val: u64) -> uint { | ||
val as uint | ||
} | ||
|
||
fn to_u64(self) -> u64 { | ||
self as u64 | ||
} | ||
} | ||
|
||
impl Token for i64 { | ||
fn from_u64(val: u64) -> i64 { | ||
val as i64 | ||
} | ||
|
||
fn to_u64(self) -> u64 { | ||
self as u64 | ||
} | ||
} | ||
|
||
impl Token for u64 { | ||
fn from_u64(val: u64) -> u64 { | ||
val | ||
} | ||
|
||
fn to_u64(self) -> u64 { | ||
self | ||
} | ||
} | ||
|
||
impl Token for () { | ||
fn from_u64(_: u64) -> () { | ||
() | ||
} | ||
|
||
fn to_u64(self) -> u64 { | ||
0 | ||
fn timeout(&mut self, reactor: &mut Reactor<T, M>, timeout: T) { | ||
} | ||
} |
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
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.