#![allow(deprecated)]
use core::marker::PhantomData;
#[deprecated(
since = "0.1.0",
note = "concurrent regions are legacy/research-tier; use the production allocator stack (`alloc-xthread`) for cross-thread allocation needs"
)]
pub struct LockFreeHandle<T> {
#[allow(clippy::missing_docs_in_private_items)]
pub(crate) index: u32,
#[allow(clippy::missing_docs_in_private_items)]
pub(crate) generation: u32,
_ty: PhantomData<fn() -> T>,
}
impl<T> LockFreeHandle<T> {
pub(crate) fn new(index: u32, generation: u32) -> Self {
Self {
index,
generation,
_ty: PhantomData,
}
}
}
impl<T> Clone for LockFreeHandle<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> Copy for LockFreeHandle<T> {}
impl<T> PartialEq for LockFreeHandle<T> {
fn eq(&self, other: &Self) -> bool {
self.index == other.index && self.generation == other.generation
}
}
impl<T> Eq for LockFreeHandle<T> {}
impl<T> core::hash::Hash for LockFreeHandle<T> {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.index.hash(state);
self.generation.hash(state);
}
}
impl<T> core::fmt::Debug for LockFreeHandle<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("LockFreeHandle")
.field("index", &self.index)
.field("generation", &self.generation)
.finish()
}
}