diff --git a/Cargo.toml b/Cargo.toml index a3782cd..de35d03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ rust-version = "1.69.0" nix = { version = "0.30", default-features = false, features = ["signal"]} [target.'cfg(target_vendor = "apple")'.dependencies] -dispatch = "0.2" +dispatch2 = "0.3" [target.'cfg(windows)'.dependencies] windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_System_Threading", "Win32_Security", "Win32_System_Console"] } diff --git a/src/platform/unix/mod.rs b/src/platform/unix/mod.rs index cdd32f6..b011a70 100644 --- a/src/platform/unix/mod.rs +++ b/src/platform/unix/mod.rs @@ -32,18 +32,22 @@ mod implementation { #[cfg(target_vendor = "apple")] mod implementation { - static mut SEMAPHORE: dispatch::ffi::dispatch_semaphore_t = std::ptr::null_mut(); + use dispatch2::{DispatchRetained, DispatchSemaphore, DispatchTime}; + + static mut SEMAPHORE: Option> = None; pub unsafe fn sem_init() { - SEMAPHORE = dispatch::ffi::dispatch_semaphore_create(0); + SEMAPHORE = Some(DispatchSemaphore::new(0)); } + #[allow(static_mut_refs)] pub unsafe fn sem_post() { - dispatch::ffi::dispatch_semaphore_signal(SEMAPHORE); + SEMAPHORE.as_deref().unwrap().signal(); } + #[allow(static_mut_refs)] pub unsafe fn sem_wait_forever() { - dispatch::ffi::dispatch_semaphore_wait(SEMAPHORE, dispatch::ffi::DISPATCH_TIME_FOREVER); + SEMAPHORE.as_deref().unwrap().wait(DispatchTime::FOREVER); } }