pub struct RiResourcePool { /* private fields */ }Expand description
Resource pool for managing multiple similar devices
This struct manages a pool of devices of the same type, tracking their availability, allocation status, and capacity. It provides methods for adding/removing devices, allocating/releasing devices, and collecting statistics.
Implementations§
Source§impl RiResourcePool
impl RiResourcePool
Sourcepub fn new(config: RiResourcePoolConfig) -> Self
pub fn new(config: RiResourcePoolConfig) -> Self
Sourcepub fn add_device(&mut self, device: Arc<RiDevice>) -> bool
pub fn add_device(&mut self, device: Arc<RiDevice>) -> bool
Sourcepub fn remove_device(&mut self, device_id: &str) -> bool
pub fn remove_device(&mut self, device_id: &str) -> bool
Sourcepub fn get_status(&self) -> RiResourcePoolStatus
pub fn get_status(&self) -> RiResourcePoolStatus
Gets the current status of the pool
This method returns a RiResourcePoolStatus struct containing information about the pool’s capacity, allocation, and utilization.
§Returns
A RiResourcePoolStatus struct with the current pool status
Sourcepub fn device_type(&self) -> RiDeviceType
pub fn device_type(&self) -> RiDeviceType
Sourcepub fn get_devices(&self) -> Vec<Arc<RiDevice>>
pub fn get_devices(&self) -> Vec<Arc<RiDevice>>
Sourcepub fn get_available_devices(&self) -> Vec<Arc<RiDevice>>
pub fn get_available_devices(&self) -> Vec<Arc<RiDevice>>
Gets available devices in the pool
§Returns
A vector of Arc<RiDevice> containing only available devices
Sourcepub fn get_allocated_devices(&self) -> Vec<Arc<RiDevice>>
pub fn get_allocated_devices(&self) -> Vec<Arc<RiDevice>>
Gets allocated devices in the pool
§Returns
A vector of Arc<RiDevice> containing only allocated devices
Sourcepub fn has_available_capacity(&self) -> bool
pub fn has_available_capacity(&self) -> bool
Checks if the pool has available capacity
§Returns
true if the pool has available devices, false otherwise
Sourcepub fn utilization_rate(&self) -> f64
pub fn utilization_rate(&self) -> f64
Gets the utilization rate of the pool (0.0 - 1.0)
§Returns
The utilization rate as a floating-point number between 0.0 and 1.0
Sourcepub fn is_healthy(&self) -> bool
pub fn is_healthy(&self) -> bool
Checks if the pool is healthy
A pool is considered healthy if it has available devices or allocated devices.
§Returns
true if the pool is healthy, false otherwise
Sourcepub fn get_statistics(&self) -> RiResourcePoolStatistics
pub fn get_statistics(&self) -> RiResourcePoolStatistics
Gets comprehensive statistics for the pool
This method calculates and returns comprehensive statistics for the pool, including device counts, utilization, total compute units, memory, storage, bandwidth, and average health score.
§Returns
A RiResourcePoolStatistics struct with comprehensive pool statistics
Trait Implementations§
Source§impl<'py> IntoPyObject<'py> for RiResourcePool
impl<'py> IntoPyObject<'py> for RiResourcePool
Source§type Target = RiResourcePool
type Target = RiResourcePool
Source§type Output = Bound<'py, <RiResourcePool as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <RiResourcePool as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for RiResourcePool
impl PyClass for RiResourcePool
Source§impl PyClassImpl for RiResourcePool
impl PyClassImpl for RiResourcePool
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = /// allocating/releasing devices, and collecting statistics.
const RAW_DOC: &'static CStr = /// allocating/releasing devices, and collecting statistics.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<RiResourcePool>
type ThreadChecker = SendablePyClass<RiResourcePool>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyTypeInfo for RiResourcePool
impl PyTypeInfo for RiResourcePool
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.impl DerefToPyAny for RiResourcePool
impl ExtractPyClassWithClone for RiResourcePool
Auto Trait Implementations§
impl Freeze for RiResourcePool
impl RefUnwindSafe for RiResourcePool
impl Send for RiResourcePool
impl Sync for RiResourcePool
impl Unpin for RiResourcePool
impl UnsafeUnpin for RiResourcePool
impl UnwindSafe for RiResourcePool
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
§fn type_check(object: &Bound<'_, PyAny>) -> bool
fn type_check(object: &Bound<'_, PyAny>) -> bool
§fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
isinstance and issubclass function. Read more