4 releases
Uses old Rust 2015
0.1.3 | Sep 10, 2016 |
---|---|
0.1.2 | Sep 2, 2016 |
0.1.1 | Aug 30, 2016 |
0.1.0 | Aug 30, 2016 |
#20 in #epoll
9KB
231 lines
xcore,is a epoll based TCP Server framework.
lib.rs
:
xcore,is a simple epoll based TCP Server framework.
Usage
pub struct Handler {
map: BTreeSet<i32>,
}
impl Handler {
pub fn add_user(&mut self, fd: i32) {
self.map.insert(fd);
}
}
// handler executed in different thread
pub fn handler(fd: i32,
socket: &mut TcpStream,
commander: Sender<Ctrl>,
handle: Arc<RwLock<Handler>>){
let wirte_handle = handle.write().unwrap();
write_handle.add_user(fd);
}
fn main() {
let h = Handler {
map: BTreeSet::new(),
};
let listen: Listener = Listener::new("127.0.0.1:6666");
let worker: Executor = Executor::new(2000,4, handler,h);
loop {
let v = listen.get_stream();
match v {
Some(v) => {
worker.add(v);
}
None => {}
}
}
}
Dependencies
~125KB