Would it make sense to create a runtime dedicated to single-threaded, extremely simple use cases? #271
Replies: 2 comments 2 replies
-
I wrote |
Beta Was this translation helpful? Give feedback.
-
To directly answer your question: I would think that it's definitely possible to implement this functionality in terms of a library. It would probably be useful, not only for embedded cases like you said but also cases where data is |
Beta Was this translation helpful? Give feedback.
-
Hi,
I recently read @notgull's post about why you might actually want async in your project. It resonated with me. I had a project that I recognized as implementing async patterns, and I used an async runtime in my tests (see my related question), but I ended up not using a runtime in my actual project. I wanted to discuss why I made that decision, to see if there is potentially room for further work on
smol
or another project.My project was implemented in an embedded Linux context, and it's job was to shuttle data bidirectionally between a Unix socket and a serial port. I wanted to keep the implementation as simple as possible, so I was pretty turned off when I started looking at the internals of Tokio. I just didn't need that level of complexity for literally two byte streams.
At the time, I hadn't given
smol
much thought. Instead, I manually implemented an event loop usingmio
. It worked, but I think using a properasync
runtime would have been more ergonomic.When I eventually looked at
smol
, I found that theasync_io::block_on
function is pretty close to what I had imagined of a minimal runtime. However, it still spawns a second thread, and it still assumes a potentially multi-threaded design. In my case, I had no desire to use multiple threads. It just wasn't necessary to handle a serial port operating at 115,200 baud.I began to wonder if there is room for something even
smoller
thansmol
, something explicitly designed for single-threaded, extremely simple use cases. It wouldn't need locks or any other synchronization. It would just poll some futures and then block onepoll_wait
or equivalent.Do you see that as a use case worthy of a dedicated library? Or is it so simple that it can be left to manual implementations like mine?
Beta Was this translation helpful? Give feedback.
All reactions