I have a future that reads from a socket via OS API. My current implementation spawns an internal thread, which polls the socket and calls the waker when there is some ready data. This internal thread seems to me an unnecessary overhead.
How to call the waker without involving additional threads?
I was thinking to call the waker immediately each time even if there would be no data to read, but this might spin the processor. It feels not right.
Another way would be to use underlying OS API to set a timer, which would interrupt some existing thread with a callback or a message. It feels like it would work, although I didn't try it yet.
Is there an established good way to call the waker without involving internal threads and without using task system specific futures like tokio::time
?