select()-able timers

后端 未结 4 999
长发绾君心
长发绾君心 2021-02-14 03:20

select() is a great system call. You can pack any number of file descriptors, socket descriptors, pipes, etc. and get notified in a synchronous fashion when input becomes availa

4条回答
  •  庸人自扰
    2021-02-14 04:03

    MarkR has a nice portable solution, but here's another:

    Use a POSIX timer (timer_create) and you can transform the problem into "select-able signals". This problem has a classic solution: writing to a pipe from the signal handler and selecting on the read end of the pipe.

提交回复
热议问题