Struct axns::AxNamespace
source · pub struct AxNamespace { /* private fields */ }
Expand description
A namespace that contains all user-defined resources.
There are two types of namespaces:
- Global namespace: this namespace is globally unique and all threads share
the resources in it. Resources are statically collected into the
axns_resource
section, and the global namespace is constructed by the base address of the section (AxNamespace::global
). - Thread-local namespace: this namespace is per-thread, each thread should
call
AxNamespace::new_thread_local()
to allocate a memory area as its namespace. Layout of resources in global and thread-local namespaces is consistent. Each namespace has its own resources, which may be unique or shared between threads by theArc
wrapper.
Implementations§
source§impl AxNamespace
impl AxNamespace
sourcepub const fn base(&self) -> *mut u8
pub const fn base(&self) -> *mut u8
Returns the base address of the namespace, which points to the start of all resources.
sourcepub fn new_thread_local() -> Self
pub fn new_thread_local() -> Self
Constructs a new thread-local namespace.
Each thread can have its own namespace instead of the global one, to isolate resources between threads.
This function allocates a memory area to store the thread-local resources, and copies from the global namespace as the initial value.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AxNamespace
impl RefUnwindSafe for AxNamespace
impl !Send for AxNamespace
impl !Sync for AxNamespace
impl Unpin for AxNamespace
impl UnwindSafe for AxNamespace
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more