tidy code for asynchronous IO

后端 未结 5 1086
醉话见心
醉话见心 2020-12-12 13:15

Whilst asynchronous IO (non-blocking descriptors with select/poll/epoll/kqueue etc) is not the most documented thing on the web, there are a handful of good examples.

<
5条回答
  •  醉酒成梦
    2020-12-12 13:53

    State machines are one nice approach. It's a bit of complexity up front that'll save you headaches in the future, where the future starts really, really soon. ;-)

    Another method is to use threads and do blocking I/O on a single fd in each thread. The trade-off here is that you make I/O simple but may introduce complexity in synchronization.

提交回复
热议问题