Can we obtain a file descriptor for a semaphore or condition variable?

前端 未结 3 496
离开以前
离开以前 2021-01-01 03:49

I have an implementation of a bi-directional message channel which, to reduce overhead, I implemented as a couple of circular buffers of messages. To write from one end to t

3条回答
  •  时光取名叫无心
    2021-01-01 04:04

    It's a bit of a hack, but you could replace your condition variable with a pipe. The read thread would poll/select on the read side and the socket. The thread that writes to your buffer also writes a byte to the pipe to signal there is stuff in the buffer.

提交回复
热议问题