Skip to main content

SharedRegion

Struct SharedRegion 

Source
pub struct SharedRegion<T: GpuValue, const OWNER: u8> { /* private fields */ }
Expand description

A region of shared memory owned by a specific role.

The key insight: shared memory races happen because ownership is implicit. By making ownership explicit, we prevent races at the type level.

OWNER is a type-level tag (u8 discriminator) that prevents cross-type access at compile time. The owner field carries the runtime lane range metadata (which lanes belong to this role). These encode different concerns: OWNER prevents mixing regions at the type level; Role describes the lane geometry.

Ownership is enforced at compile time only (const generic tag). The owner field is metadata for debugging — write/read do not verify the caller’s role at runtime. In a real GPU implementation, kernel launch guarantees would replace runtime checks.

Implementations§

Source§

impl<T: GpuValue + Default, const OWNER: u8> SharedRegion<T, OWNER>

Source

pub fn new(owner: Role) -> Self

Source§

impl<T: GpuValue, const OWNER: u8> SharedRegion<T, OWNER>

Source

pub fn write(&mut self, index: usize, value: T)

Source

pub fn read(&self, index: usize) -> T

Source

pub fn grant_read(&self) -> SharedView<'_, T, OWNER>

Source

pub fn owner(&self) -> Role

Auto Trait Implementations§

§

impl<T, const OWNER: u8> Freeze for SharedRegion<T, OWNER>
where T: Freeze,

§

impl<T, const OWNER: u8> RefUnwindSafe for SharedRegion<T, OWNER>
where T: RefUnwindSafe,

§

impl<T, const OWNER: u8> Send for SharedRegion<T, OWNER>

§

impl<T, const OWNER: u8> Sync for SharedRegion<T, OWNER>

§

impl<T, const OWNER: u8> Unpin for SharedRegion<T, OWNER>
where T: Unpin,

§

impl<T, const OWNER: u8> UnsafeUnpin for SharedRegion<T, OWNER>
where T: UnsafeUnpin,

§

impl<T, const OWNER: u8> UnwindSafe for SharedRegion<T, OWNER>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.