I have an object X
that works in its own thread and sometimes signals with (std::condition_variable) some_cv.notify_all()
.
I also have another object Y
that perfoms overlapped read from Windows named pipe. Then I need Y
to wait for either notification from some_cv
, or completion of overlapped operation.
How can I do this? One solution I came up with is following:
1) Assosiate an hEvent
with overlapped operation.
2) Spawn a thread that will wait on this hEvent
and call some_cv.notify_all()
. Then Y
should figure out why it was waken.
However, this solution needs a whole new thread with the only purpose of waiting for hEvent
and "forwarding signal" to some_cv
. Instead, it would be much better to perform read with ReadFileEx
, provide completion routine to it, and call some_cv.notify_all
directly from this routine.
The problem is that this completion routine will have a chance to run only when Y
comes to "alertable state". And I have no idea whether waiting on std::condition_variable
is alertable in Windows or not.
So is waiting on std::condition_variable
alertable in Windows? If not, what other method would you suggest?