_GetSemaphoreValue - get value of semaphore by briefly acquiring and releasing
(handle: HANDLE)
| 92 | |
| 93 | /// _GetSemaphoreValue - get value of semaphore by briefly acquiring and releasing |
| 94 | fn get_semaphore_value(handle: HANDLE) -> Result<i32, ()> { |
| 95 | match unsafe { WaitForSingleObjectEx(handle, 0, 0) } { |
| 96 | WAIT_OBJECT_0 => { |
| 97 | let mut previous: i32 = 0; |
| 98 | if unsafe { ReleaseSemaphore(handle, 1, &mut previous) } == 0 { |
| 99 | return Err(()); |
| 100 | } |
| 101 | Ok(previous + 1) |
| 102 | } |
| 103 | WAIT_TIMEOUT => Ok(0), |
| 104 | _ => Err(()), |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | #[pyclass(with(Constructor), flags(BASETYPE))] |
| 109 | impl SemLock { |
no test coverage detected