refactor: fixing type inconsistencies in cache types
This commit is contained in:
@@ -149,6 +149,18 @@ impl StructureAnchor
|
||||
}
|
||||
}
|
||||
|
||||
/// A cache might hold data owned by multiple different producers. To discriminate where to route the
|
||||
/// request, a node is always tagged by a [`ProducerId`].
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Zeroable, Pod)]
|
||||
#[repr(transparent)]
|
||||
pub struct ProducerId(pub u32);
|
||||
|
||||
/// A request can come from anywhere inside the structure. The producer can thus tag each node with
|
||||
/// a locator, to know where the request was issued.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Zeroable, Pod)]
|
||||
#[repr(transparent)]
|
||||
pub struct StructureLocator(pub u32);
|
||||
|
||||
/// Data stored alongside cache structure so that application can locate a
|
||||
/// particular request
|
||||
#[derive(Debug, Clone, Copy, Zeroable, Pod)]
|
||||
@@ -156,10 +168,10 @@ impl StructureAnchor
|
||||
pub struct LocationPage
|
||||
{
|
||||
/// Identifier for locating this particular node within the structure
|
||||
pub node_id: u32,
|
||||
pub node_id: StructureLocator,
|
||||
|
||||
/// Identifier of the producer that owns this node
|
||||
pub producer_id: u32,
|
||||
pub producer_id: ProducerId,
|
||||
|
||||
/// Opaque content identity inherited from the root request.
|
||||
pub anchor: StructureAnchor,
|
||||
@@ -196,13 +208,13 @@ impl DepthPage
|
||||
pub struct RequestInformation
|
||||
{
|
||||
/// Identifier for locating this particular node within the structure
|
||||
pub node_id: u32,
|
||||
pub node_id: StructureLocator,
|
||||
|
||||
/// The index of the children on which the request was issued
|
||||
pub children_index: u32,
|
||||
|
||||
/// Identifier of the producer that owns the requesting node
|
||||
pub producer_id: u32,
|
||||
pub producer_id: ProducerId,
|
||||
|
||||
/// The amount of times this request was emitted this frame. Higher means more urgent.
|
||||
pub demand: u32,
|
||||
@@ -274,11 +286,11 @@ pub struct InsertionParent
|
||||
/// Depth of the parent. [`NO_PARENT_PAGE`] for external roots.
|
||||
pub depth: u32,
|
||||
|
||||
/// Locator of the parent inside the structure. `0` for external roots.
|
||||
pub node_id: u32,
|
||||
/// Locator of the parent inside the structure. `StructureLocator(0)` for external roots.
|
||||
pub node_id: StructureLocator,
|
||||
|
||||
/// Producer that owns the parent.
|
||||
pub producer_id: u32,
|
||||
pub producer_id: ProducerId,
|
||||
|
||||
/// Opaque content identity of the structure the parent belongs to.
|
||||
pub anchor: StructureAnchor,
|
||||
@@ -293,8 +305,8 @@ impl InsertionParent
|
||||
/// Parent information for a child of a resident cache page.
|
||||
pub fn internal(
|
||||
meta: &RequestMeta,
|
||||
node_id: u32,
|
||||
producer_id: u32,
|
||||
node_id: StructureLocator,
|
||||
producer_id: ProducerId,
|
||||
anchor: StructureAnchor,
|
||||
) -> Self
|
||||
{
|
||||
@@ -311,14 +323,14 @@ impl InsertionParent
|
||||
}
|
||||
|
||||
/// Parent information for the root of an external structure.
|
||||
pub fn external(producer_id: u32, anchor: StructureAnchor, table_slot: u32) -> Self
|
||||
pub fn external(producer_id: ProducerId, anchor: StructureAnchor, table_slot: u32) -> Self
|
||||
{
|
||||
Self {
|
||||
kind: InsertionParentKind::EXTERNAL.raw(),
|
||||
page_index: NO_PARENT_PAGE,
|
||||
children_index: 0,
|
||||
depth: NO_PARENT_PAGE,
|
||||
node_id: 0,
|
||||
node_id: StructureLocator(0),
|
||||
producer_id,
|
||||
anchor,
|
||||
table_slot,
|
||||
|
||||
Reference in New Issue
Block a user