#![allow(deprecated)]
use core::marker::PhantomData;
use crate::concurrent::EpochHandle;
#[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 ShardedHandle<T> {
#[allow(clippy::missing_docs_in_private_items)]
pub(crate) shard: u16,
#[allow(clippy::missing_docs_in_private_items)]
pub(crate) inner: EpochHandle<T>,
_ty: PhantomData<fn() -> T>,
}
impl<T> ShardedHandle<T> {
pub(crate) fn new(shard: u16, inner: EpochHandle<T>) -> Self {
Self {
shard,
inner,
_ty: PhantomData,
}
}
#[must_use]
pub fn shard(&self) -> u16 {
self.shard
}
}
impl<T> Clone for ShardedHandle<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> Copy for ShardedHandle<T> {}
impl<T> PartialEq for ShardedHandle<T> {
fn eq(&self, other: &Self) -> bool {
self.shard == other.shard && self.inner == other.inner
}
}
impl<T> Eq for ShardedHandle<T> {}
impl<T> core::hash::Hash for ShardedHandle<T> {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.shard.hash(state);
self.inner.hash(state);
}
}
impl<T> core::fmt::Debug for ShardedHandle<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("ShardedHandle")
.field("shard", &self.shard)
.field("inner", &self.inner)
.finish()
}
}