diff --git a/src/runnable.rs b/src/runnable.rs index cada62d..ed15f5d 100644 --- a/src/runnable.rs +++ b/src/runnable.rs @@ -437,15 +437,6 @@ impl Builder { use std::task::{Context, Poll}; use std::thread::{self, ThreadId}; - #[inline] - fn thread_id() -> ThreadId { - std::thread_local! { - static ID: ThreadId = thread::current().id(); - } - ID.try_with(|id| *id) - .unwrap_or_else(|_| thread::current().id()) - } - struct Checked { id: ThreadId, inner: ManuallyDrop, @@ -454,7 +445,7 @@ impl Builder { impl Drop for Checked { fn drop(&mut self) { assert!( - self.id == thread_id(), + self.id == thread::current().id(), "local task dropped by a thread that didn't spawn it" ); unsafe { @@ -468,7 +459,7 @@ impl Builder { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { assert!( - self.id == thread_id(), + self.id == thread::current().id(), "local task polled by a thread that didn't spawn it" ); unsafe { self.map_unchecked_mut(|c| &mut *c.inner).poll(cx) } @@ -480,7 +471,7 @@ impl Builder { let future = future(meta); Checked { - id: thread_id(), + id: thread::current().id(), inner: ManuallyDrop::new(future), } };