Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/wasi/src/p2/poll.rs
1692 views
1
use crate::runtime::in_tokio;
2
use wasmtime_wasi_io::{bindings::wasi::io::poll as async_poll, poll::DynPollable};
3
4
use anyhow::Result;
5
use wasmtime::component::{Resource, ResourceTable};
6
7
impl crate::p2::bindings::sync::io::poll::Host for ResourceTable {
8
fn poll(&mut self, pollables: Vec<Resource<DynPollable>>) -> Result<Vec<u32>> {
9
in_tokio(async { async_poll::Host::poll(self, pollables).await })
10
}
11
}
12
13
impl crate::p2::bindings::sync::io::poll::HostPollable for ResourceTable {
14
fn ready(&mut self, pollable: Resource<DynPollable>) -> Result<bool> {
15
in_tokio(async { async_poll::HostPollable::ready(self, pollable).await })
16
}
17
fn block(&mut self, pollable: Resource<DynPollable>) -> Result<()> {
18
in_tokio(async { async_poll::HostPollable::block(self, pollable).await })
19
}
20
fn drop(&mut self, pollable: Resource<DynPollable>) -> Result<()> {
21
async_poll::HostPollable::drop(self, pollable)
22
}
23
}
24
25