Add support for a timeout in Semaphore::Wait().