diff --git a/src/thread.rs b/src/thread.rs index 9d17a15..c7f4d55 100644 --- a/src/thread.rs +++ b/src/thread.rs @@ -29,22 +29,22 @@ static mut THREAD_ID: libc::pthread_t = MAIN_THREAD_ID; #[derive(Copy, Clone)] struct PThread { - thread: SendPtr, + thread: ShareablePtr, os_thread_id: u32, is_detached: bool, is_finished: bool, - result: SendPtr, + result: ShareablePtr, } -/// Pointers are not Send, though it's really just a lint. This struct lets us -/// ignore that "lint". -struct SendPtr(*mut T); -unsafe impl Send for SendPtr {} -unsafe impl Sync for SendPtr {} +/// Pointers are not Send or Sync, though it's really just a lint. This struct +/// lets us ignore that "lint". +struct ShareablePtr(*mut T); +unsafe impl Send for ShareablePtr {} +unsafe impl Sync for ShareablePtr {} // We can't use the derives because they add an unnecessary T: Copy/Clone bound. -impl Copy for SendPtr {} -impl Clone for SendPtr { +impl Copy for ShareablePtr {} +impl Clone for ShareablePtr { fn clone(&self) -> Self { *self } @@ -128,11 +128,11 @@ pub unsafe extern "C" fn pthread_create( THREADS.write().insert( thread_id, PThread { - thread: SendPtr(thread), + thread: ShareablePtr(thread), os_thread_id, is_detached: false, is_finished: false, - result: SendPtr(ptr::null_mut()), + result: ShareablePtr(ptr::null_mut()), }, ); @@ -232,11 +232,11 @@ pub unsafe extern "C" fn pthread_self() -> libc::pthread_t { PThread { // This null pointer is safe because we return before ever using // it (in pthread_join and pthread_detach). - thread: SendPtr(ptr::null_mut()), + thread: ShareablePtr(ptr::null_mut()), os_thread_id, is_detached: true, is_finished: false, - result: SendPtr(ptr::null_mut()), + result: ShareablePtr(ptr::null_mut()), }, ); }