| 140 | } |
| 141 | |
| 142 | virtual void interrupt() |
| 143 | { |
| 144 | ACQUIRE(mutex); |
| 145 | |
| 146 | r->setInterrupted(true); |
| 147 | |
| 148 | pthread_kill(thread, InterruptSignal); |
| 149 | |
| 150 | // pthread_kill won't necessarily wake a thread blocked in |
| 151 | // pthread_cond_{timed}wait (it does on Linux but not Mac OS), |
| 152 | // so we signal the condition as well: |
| 153 | int rv UNUSED = pthread_cond_signal(&condition); |
| 154 | expect(s, rv == 0); |
| 155 | } |
| 156 | |
| 157 | virtual bool getAndClearInterrupted() |
| 158 | { |