Skip to content

Commit

Permalink
📝 remove nightly thread_local
Browse files Browse the repository at this point in the history
  • Loading branch information
Xudong-Huang committed Sep 1, 2024
1 parent 9cc35be commit 8a04a05
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 12 deletions.
3 changes: 0 additions & 3 deletions src/io/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ impl EventLoop {
/// Keep spinning the event loop indefinitely, and notify the handler whenever
/// any of the registered handles are ready.
pub fn run(&self, id: usize) {
#[cfg(nightly)]
WORKER_ID.set(id);
#[cfg(not(nightly))]
WORKER_ID.with(|worker_id| worker_id.set(id));

let mut events_buf: [SysEvent; IO_POLLS_MAX] = unsafe { std::mem::zeroed() };
let mut next_expire = None;
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
//! * Both x86_64 GNU/Linux, x86_64 Windows, x86_64 Mac OS are supported.
// #![deny(missing_docs)]
#![cfg_attr(nightly, feature(thread_local))]

#[macro_use]
extern crate log;
Expand Down
8 changes: 0 additions & 8 deletions src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ use may_queue::spmc::{self, Local, Steal};
use may_queue::spsc::Queue as Local;

// thread id, only workers are normal ones
#[cfg(nightly)]
#[thread_local]
pub static WORKER_ID: Cell<usize> = Cell::new(usize::MAX);

#[cfg(not(nightly))]
thread_local! { pub static WORKER_ID: Cell<usize> = const { Cell::new(usize::MAX) }; }

// here we use Arc<AtomicOption<>> for that in the select implementation
Expand Down Expand Up @@ -173,10 +168,7 @@ impl Scheduler {
/// put the coroutine to correct queue so that next time it can be scheduled
#[inline]
pub fn schedule(&self, co: CoroutineImpl) {
#[cfg(nightly)]
let id = WORKER_ID.get();
#[cfg(not(nightly))]
let id = WORKER_ID.with(|id| id.get());

if id != usize::MAX {
self.schedule_with_id(co, id);
Expand Down

0 comments on commit 8a04a05

Please sign in to comment.