Hacker News new | ask | show | jobs
by avdicius 3815 days ago
I use pthreads and coroutines (actually fibers) inside pthreads and lock-free bounded queues to communicate between pthreads. All pthreads execute coroutines until all of them get blocked, then pthreads go to epoll. If a pthread gets a socket readiness notification for a socket it owns or an orphan socket then it handles I/O itself, without any synchronization. If a socket is owned by a coroutine running on a different pthread then the notification is forwarded to that pthread via the bounded queue. The project is called MainMemory, and it is just here on Show HN.