Skip to content

Commit 0293543

Browse files
use AtomicUsize
1 parent abde052 commit 0293543

File tree

3 files changed

+5
-52
lines changed

3 files changed

+5
-52
lines changed

src/sync/atomic.rs

-42
This file was deleted.

src/sync/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,6 @@ pub use rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
182182
mod mutex;
183183
mod rwlock;
184184

185-
cfg_default! {
186-
pub(crate) mod atomic;
187-
}
188-
189185
cfg_unstable! {
190186
pub use barrier::{Barrier, BarrierWaitResult};
191187
pub use channel::{channel, Sender, Receiver, RecvError, TryRecvError, TrySendError};

src/task/task_id.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use std::fmt;
2-
use std::sync::atomic::Ordering;
3-
4-
use crate::sync::atomic::AtomicU64;
2+
use std::sync::atomic::{AtomicUsize, Ordering};
53

64
/// A unique identifier for a task.
75
///
@@ -15,15 +13,16 @@ use crate::sync::atomic::AtomicU64;
1513
/// })
1614
/// ```
1715
#[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)]
18-
pub struct TaskId(pub(crate) u64);
16+
pub struct TaskId(pub(crate) usize);
1917

2018
impl TaskId {
2119
/// Generates a new `TaskId`.
2220
pub(crate) fn generate() -> TaskId {
23-
static COUNTER: AtomicU64 = AtomicU64::new(1);
21+
// TODO: find a good version to emulate u64 atomics on 32 bit systems.
22+
static COUNTER: AtomicUsize = AtomicUsize::new(1);
2423

2524
let id = COUNTER.fetch_add(1, Ordering::Relaxed);
26-
if id > u64::max_value() / 2 {
25+
if id > usize::max_value() / 2 {
2726
std::process::abort();
2827
}
2928
TaskId(id)

0 commit comments

Comments
 (0)