Skip to content

Commit

Permalink
Merge pull request #977 from staltz/support-32-archs
Browse files Browse the repository at this point in the history
Lifecycle supports 32-bit architectures
  • Loading branch information
kjvalencik authored Mar 23, 2023
2 parents fe4642e + 641b4d2 commit 3e83d73
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions crates/neon/src/lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::{
any::Any,
marker::PhantomData,
sync::{
atomic::{AtomicU64, Ordering},
atomic::{AtomicU32, Ordering},
Arc,
},
};
Expand All @@ -31,13 +31,17 @@ use crate::{
///
/// _Note_: Since `InstanceData` is created lazily, the order of `id` may not
/// reflect the order that instances were created.
pub(crate) struct InstanceId(u64);
pub(crate) struct InstanceId(u32);

impl InstanceId {
fn next() -> Self {
static NEXT_ID: AtomicU64 = AtomicU64::new(0);
static NEXT_ID: AtomicU32 = AtomicU32::new(0);

Self(NEXT_ID.fetch_add(1, Ordering::SeqCst))
let next = NEXT_ID.fetch_add(1, Ordering::SeqCst).checked_add(1);
match next {
Some(id) => Self(id),
None => panic!("u32 overflow ocurred in Lifecycle InstanceId"),
}
}
}

Expand Down

0 comments on commit 3e83d73

Please sign in to comment.