diff --git a/iceoryx2-bb/posix/src/barrier.rs b/iceoryx2-bb/posix/src/barrier.rs index b9f8c3266..00806e133 100644 --- a/iceoryx2-bb/posix/src/barrier.rs +++ b/iceoryx2-bb/posix/src/barrier.rs @@ -213,7 +213,7 @@ impl<'a> Barrier<'a> { } impl<'a> IpcConstructible<'a, BarrierHandle> for Barrier<'a> { - fn new(handle: &'a BarrierHandle) -> Barrier { + fn new(handle: &BarrierHandle) -> Barrier { Barrier { handle } } } diff --git a/iceoryx2-bb/posix/src/thread.rs b/iceoryx2-bb/posix/src/thread.rs index 2a36f6db4..cef9be0d8 100644 --- a/iceoryx2-bb/posix/src/thread.rs +++ b/iceoryx2-bb/posix/src/thread.rs @@ -159,11 +159,6 @@ enum_gen! { FailedToSetAffinity <= ThreadSetAffinityError } -/// Terminates the callers thread -pub fn thread_exit() -> ! { - unsafe { posix::pthread_exit(std::ptr::null_mut::()) } -} - /// Describes the scope in which a thread is competing with other threads for CPU time. #[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)] #[repr(i32)] @@ -803,11 +798,6 @@ impl<'thread> Thread<'thread> { v => (UnknownError(v as i32), "{} {:?} since an unknown error occurred ({})", msg, signal, v) ); } - - /// Terminates the current thread. - pub fn cancel(&mut self) -> bool { - unsafe { posix::pthread_cancel(self.handle.handle) != 0 } - } } impl<'thread> ThreadProperties for Thread<'thread> { diff --git a/iceoryx2-bb/posix/tests/thread_tests.rs b/iceoryx2-bb/posix/tests/thread_tests.rs index 7213653af..c9d196cd5 100644 --- a/iceoryx2-bb/posix/tests/thread_tests.rs +++ b/iceoryx2-bb/posix/tests/thread_tests.rs @@ -198,44 +198,3 @@ fn thread_destructor_does_block_on_busy_thread() { drop(thread); assert_that!(start.elapsed(), time_at_least SLEEP_DURATION); } - -#[test] -fn thread_cancel_works() { - let barrier = Arc::new(Barrier::new(2)); - let mut thread = { - let barrier = barrier.clone(); - ThreadBuilder::new() - .affinity(0) - .spawn(move || { - barrier.wait(); - loop { - // NOTE we have to use 'sleep' instead of 'barrier.wait()' since the latter blocks cancellation - std::thread::sleep(Duration::from_millis(100)); - } - }) - .unwrap() - }; - - // if the thread is not executed we observe a deadlock here - barrier.wait(); - thread.cancel(); -} - -#[test] -fn thread_exit_works() { - let _thread = { - ThreadBuilder::new() - .affinity(0) - .spawn(move || { - // TODO: [#258] This sleep prevents a 'SIGABRT' on Linux with release builds with rustc v1.81.0-nightly! - #[cfg(target_os = "linux")] - std::thread::sleep(Duration::from_nanos(1)); - thread_exit(); - #[allow(unreachable_code)] - { - panic!("This should not happen when 'thread_exit' works as intended"); - } - }) - .unwrap() - }; -} diff --git a/iceoryx2-pal/posix/src/freebsd/pthread.rs b/iceoryx2-pal/posix/src/freebsd/pthread.rs index 33abe247e..ec91f3574 100644 --- a/iceoryx2-pal/posix/src/freebsd/pthread.rs +++ b/iceoryx2-pal/posix/src/freebsd/pthread.rs @@ -126,14 +126,6 @@ pub unsafe fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: size internal::pthread_getname_np(thread, name, len) } -pub unsafe fn pthread_cancel(thread: pthread_t) -> int { - crate::internal::pthread_cancel(thread) -} - -pub unsafe fn pthread_exit(value_ptr: *mut void) -> ! { - crate::internal::pthread_exit(value_ptr) -} - pub unsafe fn pthread_kill(thread: pthread_t, sig: int) -> int { internal::pthread_kill(thread, sig) } diff --git a/iceoryx2-pal/posix/src/linux/pthread.rs b/iceoryx2-pal/posix/src/linux/pthread.rs index c31e06307..2364a99b8 100644 --- a/iceoryx2-pal/posix/src/linux/pthread.rs +++ b/iceoryx2-pal/posix/src/linux/pthread.rs @@ -126,14 +126,6 @@ pub unsafe fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: size internal::pthread_getname_np(thread, name, len) } -pub unsafe fn pthread_cancel(thread: pthread_t) -> int { - crate::internal::pthread_cancel(thread) -} - -pub unsafe fn pthread_exit(value_ptr: *mut void) -> ! { - crate::internal::pthread_exit(value_ptr) -} - pub unsafe fn pthread_kill(thread: pthread_t, sig: int) -> int { internal::pthread_kill(thread, sig) } diff --git a/iceoryx2-pal/posix/src/macos/pthread.rs b/iceoryx2-pal/posix/src/macos/pthread.rs index f57f6ca9a..d0d8d6c95 100644 --- a/iceoryx2-pal/posix/src/macos/pthread.rs +++ b/iceoryx2-pal/posix/src/macos/pthread.rs @@ -357,14 +357,6 @@ pub unsafe fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: size Errno::ESUCCES as _ } -pub unsafe fn pthread_cancel(thread: pthread_t) -> int { - crate::internal::pthread_cancel(thread) -} - -pub unsafe fn pthread_exit(value_ptr: *mut void) -> ! { - crate::internal::pthread_exit(value_ptr) -} - pub unsafe fn pthread_kill(_thread: pthread_t, _sig: int) -> int { todo!() } diff --git a/iceoryx2-pal/posix/src/windows/pthread.rs b/iceoryx2-pal/posix/src/windows/pthread.rs index 87d72cd82..f2ece5555 100644 --- a/iceoryx2-pal/posix/src/windows/pthread.rs +++ b/iceoryx2-pal/posix/src/windows/pthread.rs @@ -29,7 +29,7 @@ use windows_sys::Win32::{ System::{ Memory::LocalFree, Threading::{ - CreateThread, ExitThread, GetCurrentThread, GetCurrentThreadId, GetExitCodeThread, + CreateThread, GetCurrentThread, GetCurrentThreadId, GetExitCodeThread, GetThreadDescription, GetThreadId, SetThreadAffinityMask, SetThreadDescription, SetThreadPriority, TerminateThread, WaitForSingleObject, WaitOnAddress, WakeByAddressAll, WakeByAddressSingle, INFINITE, THREAD_PRIORITY_ABOVE_NORMAL, @@ -396,15 +396,6 @@ pub unsafe fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: size Errno::ESUCCES as int } -pub unsafe fn pthread_cancel(thread: pthread_t) -> int { - TerminateThread(thread.handle, 0); - Errno::ESUCCES as int -} - -pub unsafe fn pthread_exit(value_ptr: *mut void) -> ! { - ExitThread(0); -} - pub unsafe fn pthread_kill(thread: pthread_t, sig: int) -> int { TerminateThread(thread.handle, 0); Errno::ESUCCES as int