mirror of
https://github.com/denoland/deno.git
synced 2024-12-11 01:58:05 -05:00
5b9620df7a
Implements fast scheduling of deferred op futures. ```rs #[op(fast)] async fn op_read( state: Rc<RefCell<OpState>>, rid: ResourceId, buf: &mut [u8], ) -> Result<u32, Error> { // ... } ``` The future is scheduled via a fast API call and polled by the event loop after being woken up by its waker.
9 lines
364 B
Rust
9 lines
364 B
Rust
fn op_listen(state: &mut OpState) -> Result<ResourceId, Error> {
|
|
log::debug!("listen");
|
|
let addr = "127.0.0.1:4570".parse::<SocketAddr>().unwrap();
|
|
let std_listener = std::net::TcpListener::bind(&addr)?;
|
|
std_listener.set_nonblocking(true)?;
|
|
let listener = TcpListener::try_from(std_listener)?;
|
|
let rid = state.resource_table.add(listener);
|
|
Ok(rid)
|
|
}
|