MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_semaphore_value

Function get_semaphore_value

crates/stdlib/src/multiprocessing.rs:94–106  ·  view source on GitHub ↗

_GetSemaphoreValue - get value of semaphore by briefly acquiring and releasing

(handle: HANDLE)

Source from the content-addressed store, hash-verified

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 {

Callers 2

_get_valueMethod · 0.85
_is_zeroMethod · 0.85

Calls 1

ErrClass · 0.50

Tested by

no test coverage detected