How to write async code in mojo🔥?

I saw the devblogs saying that mojo currently lacks wrappers for async fn awating, however it supports the coroutines themselves. If it is possible, how does one write a function that, say, prints whichever result is faster from functions a() and b()?

I am trying to write a Thread manager for my project that heavily interfaces with the filesystem, which means a lot of recursion, shared cache, etc

Last discussion regarding this was over a month ago, did anything change?

There is a proposal being actively discussed: [proposal] Structured Async for Mojo by owenhilyard · Pull Request #3945 · modular/mojo · GitHub

1 Like

As you can see from my proposal, async doesn’t really exist yet. If you can, a manual state machine with GitHub - dmitry-salin/io_uring: The io_uring library for Mojo (that may need some updates) is probably going to be the best for a while, since I want us to know what async will look like before we set the io traits in stone.

As for how to determine whether a or b is faster, use the benchmark module.