Struct jazz::object_pool::ObjectPool
source · pub struct ObjectPool { /* private fields */ }
Expand description
An object pool that provides the backing object storage for executors.
Implementations§
source§impl ObjectPool
impl ObjectPool
pub fn new() -> ObjectPool
sourcepub fn get<'a>(&self, id: usize) -> ObjectHandle<'a>
pub fn get<'a>(&self, id: usize) -> ObjectHandle<'a>
Gets a handle to the object at id
.
The handle can be passed around safely and the underlying object will not be garbage collected until all handles to it are released.
If the object pool gets destroyed before all handles are dropped, the process will be aborted because of memory unsafety introduced by reference invalidation.
sourcepub fn get_direct(&self, id: usize) -> &dyn Object
pub fn get_direct(&self, id: usize) -> &dyn Object
Gets a direct reference to the object at id
.
sourcepub fn get_direct_typed<T: 'static>(&self, id: usize) -> Option<&T>
pub fn get_direct_typed<T: 'static>(&self, id: usize) -> Option<&T>
Gets a direct typed reference to the object at id
.
If downcast fails, None
is returned.
sourcepub fn must_get_direct_typed<T: 'static>(&self, id: usize) -> &T
pub fn must_get_direct_typed<T: 'static>(&self, id: usize) -> &T
Gets a direct reference to the object at id
.
If downcast fails, this raises a RuntimeError
.
sourcepub fn get_typed<'a, T: 'static>(
&self,
id: usize
) -> Option<TypedObjectHandle<'a, T>>
pub fn get_typed<'a, T: 'static>(
&self,
id: usize
) -> Option<TypedObjectHandle<'a, T>>
Gets a typed object handle to the object at id
.
If downcast fails, None
is returned.
sourcepub fn must_get_typed<'a, T: 'static>(
&self,
id: usize
) -> TypedObjectHandle<'a, T>
pub fn must_get_typed<'a, T: 'static>(
&self,
id: usize
) -> TypedObjectHandle<'a, T>
Gets a typed object handle to the object at id
.
If downcast fails, this raises a RuntimeError
.