stakker async await #26
-
I have been looking at async await (https://github.com/uazu/stakker_async_await) but do not understand how to use it in a method of an actor that can be executed with the call! macro. I order to use a ret_to_future inside the method, the method needs to be async. However, calling that async method with call! macro, gives an error. Could you perhaps give an example how to use ret_to_future in an actor's method? Or perhaps this is not supported, in that case I am curious to know what the use case is of stakker async await. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
So I looked a bit further, and was able to to use a ret_to_future with spawn_future in an actor method. I am still researching what the actual benefits are, because within and between actors, it seems simpler to use the regular Ret instance. |
Beta Was this translation helpful? Give feedback.
-
This crate is a proof-of-concept for integration between Stakker and Futures, Streams, the async/await ecosystem, etc. As you probably know, a lot of async/await code depends on a particular runtime. There is little I can do about that. However I can try to support async/await code which is designed to work with any runtime. So the benefit of combining If you look under tests there are some more examples there. I wrote all this code to contribute to the async/await investigation that Niko did some time ago. I think the general aim is to try and see if we can meet in the middle somehow, i.e. create an ecosystem of code which doesn't depend on a particular runtime. However until there is a fair amount of code out there that is runtime-independent, perhaps there isn't too much use for this crate. If you have a particular use-case and this crate is almost what you need, I'd be happy to look at extending it to try and cover what you need. Another direction I might possibly go with this is to use it as a way to support actor coroutines written with async/await syntax. However there is a problem of getting borrows through the context, meaning dynamic checks are required, and I was kind of leaning towards another slightly purer way of implementing those, even though it would be more work. |
Beta Was this translation helpful? Give feedback.
-
@uazu: Are you aware of Glommio? Glommio is a thread-per-core async runtime for Rust, and I'm wondering if there would be any benefit to integrate with the async ecosystem via Glommio, instead of something like Glommio currently doesn't have much support in the Rust community, so this wouldn't solve any problem in regard to crates that are written for specific runtimes, but I thought maybe there could be some benefit because both systems are thread-per-core. |
Beta Was this translation helpful? Give feedback.
This crate is a proof-of-concept for integration between Stakker and Futures, Streams, the async/await ecosystem, etc. As you probably know, a lot of async/await code depends on a particular runtime. There is little I can do about that. However I can try to support async/await code which is designed to work with any runtime. So the benefit of combining
spawn_future
andret_to_future
(or similar) would mean that some async/await library that worked directly with Futures or Streams could be called from Stakker, and would operate asynchronously alongside Stakker-based code in the same thread. Right now cross-thread waking is not yet implemented, but is in principle not too hard to add.If yo…