| 59 | |
| 60 | |
| 61 | void Event::wait(void) |
| 62 | { |
| 63 | #ifdef _WIN32 |
| 64 | |
| 65 | if(WaitForSingleObject(event, INFINITE) == WAIT_FAILED) |
| 66 | throw(W32Error("Event::wait()")); |
| 67 | |
| 68 | #else |
| 69 | |
| 70 | int ret; |
| 71 | if((ret = pthread_mutex_lock(&mutex)) != 0) |
| 72 | throw(Error("Event::wait()", strerror(ret))); |
| 73 | while(!ready && !deadYet) |
| 74 | { |
| 75 | if((ret = pthread_cond_wait(&cond, &mutex)) != 0) |
| 76 | { |
| 77 | pthread_mutex_unlock(&mutex); |
| 78 | throw(Error("Event::wait()", strerror(ret))); |
| 79 | } |
| 80 | } |
| 81 | ready = false; |
| 82 | if((ret = pthread_mutex_unlock(&mutex)) != 0) |
| 83 | throw(Error("Event::wait()", strerror(ret))); |
| 84 | |
| 85 | #endif |
| 86 | } |
| 87 | |
| 88 | |
| 89 | void Event::signal(void) |