Skip to content

Commit

Permalink
refactor: Use AtomicUsize instead of AtomicU64
Browse files Browse the repository at this point in the history
Co-authored-by: Jonas Smedegaard <[email protected]>
  • Loading branch information
duesee and jonassmedegaard committed Dec 4, 2024
1 parent 9dbfec9 commit 7bd8e3f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/handle.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{
fmt::{Debug, Formatter},
marker::PhantomData,
sync::atomic::{AtomicU64, Ordering},
sync::atomic::{AtomicUsize, Ordering},
};

pub trait Handle {
Expand All @@ -10,16 +10,16 @@ pub trait Handle {

#[derive(Clone, Copy, Eq, PartialEq, Hash)]
pub struct RawHandle {
generator_id: u64,
handle_id: u64,
generator_id: usize,
handle_id: usize,
}

impl RawHandle {
pub fn generator_id(&self) -> u64 {
pub fn generator_id(&self) -> usize {
self.generator_id
}

pub fn handle_id(&self) -> u64 {
pub fn handle_id(&self) -> usize {
self.handle_id
}
}
Expand All @@ -28,8 +28,8 @@ pub struct HandleGenerator<H: Handle> {
/// This ID is used to bind the handles to the generator instance, i.e. it's possible to
/// distinguish handles generated by different generators. We hope that this might
/// prevent bugs when the library user is dealing with handles from different sources.
generator_id: u64,
next_handle_id: u64,
generator_id: usize,
next_handle_id: usize,
_h: PhantomData<H>,
}

Expand All @@ -55,14 +55,14 @@ impl<H: Handle> HandleGenerator<H> {
}

pub struct HandleGeneratorGenerator<H: Handle> {
next_handle_generator_id: AtomicU64,
next_handle_generator_id: AtomicUsize,
_h: PhantomData<H>,
}

impl<H: Handle> HandleGeneratorGenerator<H> {
pub const fn new() -> Self {
Self {
next_handle_generator_id: AtomicU64::new(0),
next_handle_generator_id: AtomicUsize::new(0),
_h: PhantomData,
}
}
Expand Down

0 comments on commit 7bd8e3f

Please sign in to comment.