| 18 | } |
| 19 | |
| 20 | void Semaphore::WaitTimeout(long timeout){ |
| 21 | __sync_fetch_and_sub(&value, 1); |
| 22 | if(value < 0){ |
| 23 | thread_t* cThread = GetCPULocal()->currentThread; |
| 24 | acquireLock(&cThread->stateLock); |
| 25 | blocked.add_back(cThread); |
| 26 | if(value >= 0){ |
| 27 | blocked.remove(cThread); |
| 28 | releaseLock(&cThread->stateLock); |
| 29 | return; |
| 30 | } |
| 31 | releaseLock(&cThread->stateLock); |
| 32 | Timer::SleepCurrentThread(timeout); // TODO: Find a better way to do this |
| 33 | } |
| 34 | } |
no test coverage detected