diff --git a/iceoryx2-pal/concurrency-sync/tests/condition_variable_tests.rs b/iceoryx2-pal/concurrency-sync/tests/condition_variable_tests.rs index aeb490b75..1e3f85972 100644 --- a/iceoryx2-pal/concurrency-sync/tests/condition_variable_tests.rs +++ b/iceoryx2-pal/concurrency-sync/tests/condition_variable_tests.rs @@ -94,7 +94,7 @@ fn condition_variable_notify_one_unblocks_one() { let counter_old = counter.load(Ordering::Relaxed); for i in 0..NUMBER_OF_THREADS { - sut.notify(|_| { + sut.notify_one(|_| { triggered_thread.fetch_add(1, Ordering::Relaxed); }); @@ -142,7 +142,7 @@ fn condition_variable_notify_all_unblocks_all() { std::thread::sleep(TIMEOUT); let counter_old = counter.load(Ordering::Relaxed); - sut.notify(|_| { + sut.notify_all(|_| { triggered_thread.fetch_add(1, Ordering::Relaxed); }); @@ -192,12 +192,10 @@ fn condition_variable_mutex_is_locked_when_wait_returns() { std::thread::sleep(TIMEOUT); let counter_old = counter.load(Ordering::Relaxed); - for _ in 0..NUMBER_OF_THREADS { - sut.notify(|_| { - triggered_thread.fetch_add(1, Ordering::Relaxed); - }); - std::thread::sleep(TIMEOUT); - } + sut.notify_all(|_| { + triggered_thread.fetch_add(1, Ordering::Relaxed); + }); + std::thread::sleep(TIMEOUT); assert_that!(counter_old, eq 0); }); diff --git a/iceoryx2-pal/concurrency-sync/tests/semaphore_tests.rs b/iceoryx2-pal/concurrency-sync/tests/semaphore_tests.rs index a3d6eeada..b02551389 100644 --- a/iceoryx2-pal/concurrency-sync/tests/semaphore_tests.rs +++ b/iceoryx2-pal/concurrency-sync/tests/semaphore_tests.rs @@ -30,9 +30,7 @@ fn semaphore_post_and_try_wait_works() { } assert_that!(!sut.try_wait(), eq true); - for _ in 0..initial_value { - sut.post(|_| {}); - } + sut.post(|_| {}, initial_value); for _ in 0..initial_value { assert_that!(sut.try_wait(), eq true); @@ -50,9 +48,7 @@ fn semaphore_post_and_wait_works() { } assert_that!(!sut.wait(|_, _| false), eq true); - for _ in 0..initial_value { - sut.post(|_| {}); - } + sut.post(|_| {}, initial_value); for _ in 0..initial_value { assert_that!(sut.wait(|_, _| false), eq true); @@ -74,7 +70,7 @@ fn semaphore_wait_blocks() { std::thread::sleep(TIMEOUT); let old_counter = counter.load(Ordering::Relaxed); - sut.post(|_| {}); + sut.post(|_| {}, 1); assert_that!(old_counter, eq 0); }); diff --git a/iceoryx2-pal/posix/src/windows/pthread.rs b/iceoryx2-pal/posix/src/windows/pthread.rs index b3f909381..e214c4a30 100644 --- a/iceoryx2-pal/posix/src/windows/pthread.rs +++ b/iceoryx2-pal/posix/src/windows/pthread.rs @@ -693,14 +693,14 @@ pub unsafe fn pthread_rwlock_timedrdlock( } pub unsafe fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> int { - (*cond).cv.notify(|atomic| { + (*cond).cv.notify_all(|atomic| { WakeByAddressAll((atomic as *const AtomicU32).cast()); }); Errno::ESUCCES as _ } pub unsafe fn pthread_cond_signal(cond: *mut pthread_cond_t) -> int { - (*cond).cv.notify(|atomic| { + (*cond).cv.notify_one(|atomic| { WakeByAddressSingle((atomic as *const AtomicU32).cast()); }); Errno::ESUCCES as _ @@ -767,7 +767,7 @@ pub unsafe fn pthread_cond_timedwait( 4, timeout as _, ), ignore ERROR_TIMEOUT }; - true + false }, |atomic, value| { win32call! { WaitOnAddress( diff --git a/iceoryx2-pal/posix/src/windows/semaphore.rs b/iceoryx2-pal/posix/src/windows/semaphore.rs index aa3a6536d..540d53b3f 100644 --- a/iceoryx2-pal/posix/src/windows/semaphore.rs +++ b/iceoryx2-pal/posix/src/windows/semaphore.rs @@ -37,9 +37,12 @@ pub unsafe fn sem_post(sem: *mut sem_t) -> int { return -1; } - (*sem).semaphore.post(|atomic| { - WakeByAddressSingle((atomic as *const AtomicU32).cast()); - }); + (*sem).semaphore.post( + |atomic| { + WakeByAddressSingle((atomic as *const AtomicU32).cast()); + }, + 1, + ); Errno::set(Errno::ESUCCES); 0