Hacker Newsnew | past | comments | ask | show | jobs | submitlogin



That's an API. Like asyncio in Python is an API. If you make the event loop swapable without making this API mandatory however, it's never going to be a protocol.


The api is mandatory; it’s how async/await works.


So everybody has to implement a task for any alternative event loop and accept tasks from other implementation ?


Yep. You build your event loop to take structs implementing the Future trait. The futures don't care about the executor, and it's easy to switch from an event loop running on the current thread to a thread pool, if needed.


Great. I wish we have done the same.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: