1 use crate::runtime::in_tokio; 2 use wasmtime_wasi_io::{bindings::wasi::io::poll as async_poll, poll::DynPollable}; 3 4 use wasmtime::Result; 5 use wasmtime::component::{Resource, ResourceTable}; 6 7 impl crate::p2::bindings::sync::io::poll::Host for ResourceTable { poll(&mut self, pollables: Vec<Resource<DynPollable>>) -> Result<Vec<u32>>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 { ready(&mut self, pollable: Resource<DynPollable>) -> Result<bool>14 fn ready(&mut self, pollable: Resource<DynPollable>) -> Result<bool> { 15 in_tokio(async { async_poll::HostPollable::ready(self, pollable).await }) 16 } block(&mut self, pollable: Resource<DynPollable>) -> Result<()>17 fn block(&mut self, pollable: Resource<DynPollable>) -> Result<()> { 18 in_tokio(async { async_poll::HostPollable::block(self, pollable).await }) 19 } drop(&mut self, pollable: Resource<DynPollable>) -> Result<()>20 fn drop(&mut self, pollable: Resource<DynPollable>) -> Result<()> { 21 async_poll::HostPollable::drop(self, pollable) 22 } 23 } 24