
vicente.botet wrote:
Well all depends, on how the Semaphore::timed_wait is implemented.
Exactly. It should be just a call to sem_timedwait() on posix. Other implementations are possible. Anyway, on posix any proper implementation of semaphore::timed_wait() should be more efficient than condition_variable::timed_wait(), because condition_variable::timed_wait() has to lock a mutex in order to return.
I can use the sem_ family functions where available. That is, probably, the most correct solution.
But we need a implementation on the other platforms.
Other platforms should have some implementation of semaphore. On windows there's CreateSemaphore(), etc. For some platform which doesn't have semaphores it is possible to implement one using a pipe. BR, Dmitry