Skip to content

Commit 72b03a6

Browse files
committed
implement Reactor for Runtime
1 parent bd0dc35 commit 72b03a6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/runtime.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,28 @@ impl<RK: RuntimeKit + 'static> Executor for Runtime<RK> {
4949
}
5050
}
5151

52+
#[async_trait]
53+
impl<RK: RuntimeKit + Sync + 'static> Reactor for Runtime<RK> {
54+
fn register<H: IO + Send + 'static>(
55+
&self,
56+
socket: IOHandle<H>,
57+
) -> io::Result<impl AsyncIOHandle + Send> {
58+
self.kit.register(socket)
59+
}
60+
61+
async fn sleep(&self, dur: Duration) {
62+
self.kit.sleep(dur).await;
63+
}
64+
65+
fn interval(&self, dur: Duration) -> impl Stream<Item = Instant> {
66+
self.kit.interval(dur)
67+
}
68+
69+
async fn tcp_connect(&self, addr: SocketAddr) -> io::Result<impl AsyncIOHandle + Send> {
70+
self.kit.tcp_connect(addr).await
71+
}
72+
}
73+
5274
/// Wrapper around separate Executor and Reactor implementing RuntimeKit
5375
#[derive(Debug)]
5476
pub struct RuntimeParts<E: Executor, R: Reactor> {

0 commit comments

Comments
 (0)