Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lifecycle supports 32-bit architectures #977

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
staltz marked this conversation as resolved.
Show resolved Hide resolved

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