You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey all, I am trying to bolt tokio onto an external event loop (libuv via a Nodejs addon).
For this, I need to enter tokio and manually drive futures to completion using a current thread scheduler which does not block if there are pending futures.
Essentially, I need it to loop over all of the internal futures, poll them, continuing on pending futures.
Currently tokio only has the block_on method which blocks the main thread (consequently blocking the external event loop). I essentially need a try_next_tick() method.
I've been trying to reconstruct the CurrentThread scheduler in user code but almost all of the internals required to do this are private to the tokio crate - and I don't want to fork Tokio.
Is there an obvious way to achieve this that I am missing?
I was able to achieve this successfully with smol::LocalExecutor::try_tick() but I'd rather use Tokio.
Trying to get this working with Tokio in a sandbox I am trying the following:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey all, I am trying to bolt tokio onto an external event loop (libuv via a Nodejs addon).
For this, I need to enter tokio and manually drive futures to completion using a current thread scheduler which does not block if there are pending futures.
Essentially, I need it to loop over all of the internal futures, poll them, continuing on pending futures.
Currently tokio only has the
block_on
method which blocks the main thread (consequently blocking the external event loop). I essentially need atry_next_tick()
method.I've been trying to reconstruct the
CurrentThread
scheduler in user code but almost all of the internals required to do this are private to the tokio crate - and I don't want to fork Tokio.Is there an obvious way to achieve this that I am missing?
I was able to achieve this successfully with
smol::LocalExecutor::try_tick()
but I'd rather use Tokio.Trying to get this working with Tokio in a sandbox I am trying the following:
I have tried using a
LocalSet
but I figure if I can run a single future like this, I can run aLocalSet
like this so I am starting simpleEDIT: I am trying to achieve something similar to this
Beta Was this translation helpful? Give feedback.
All reactions