Wait for (decrement) self until the specified timeout has elapsed.
(&self, timeout: Duration)
| 34 | |
| 35 | /// Wait for (decrement) self until the specified timeout has elapsed. |
| 36 | pub fn wait_timeout(&self, timeout: Duration) -> Result<(), WaitTimeout> { |
| 37 | let when = time_after_delay(timeout); |
| 38 | let result = unsafe { |
| 39 | dispatch_semaphore_wait(self.ptr, when) |
| 40 | }; |
| 41 | if result == 0 { |
| 42 | Ok(()) |
| 43 | } else { |
| 44 | Err(WaitTimeout { duration: timeout }) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | /// Signal (increment) self. |
| 49 | /// |