This commit is contained in:
parent
145b50347d
commit
317a3b833d
@ -1,16 +1,6 @@
|
|||||||
//! # Pool implementation providing pre-allocated sub-pools with fixed size memory blocks
|
//! # Pool implementation providing memory pools for packet storage.
|
||||||
//!
|
//!
|
||||||
//! This is a simple memory pool implementation which pre-allocates all sub-pools using a given pool
|
//! # Example for the [StaticMemoryPool]
|
||||||
//! configuration. After the pre-allocation, no dynamic memory allocation will be performed
|
|
||||||
//! during run-time. This makes the implementation suitable for real-time applications and
|
|
||||||
//! embedded environments. The pool implementation will also track the size of the data stored
|
|
||||||
//! inside it.
|
|
||||||
//!
|
|
||||||
//! Transactions with the [pool][LocalPool] are done using a special [address][StoreAddr] type.
|
|
||||||
//! Adding any data to the pool will yield a store address. Modification and read operations are
|
|
||||||
//! done using a reference to a store address. Deletion will consume the store address.
|
|
||||||
//!
|
|
||||||
//! # Example
|
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use satrs_core::pool::{StaticMemoryPool, StaticPoolConfig, PoolProvider};
|
//! use satrs_core::pool::{StaticMemoryPool, StaticPoolConfig, PoolProvider};
|
||||||
@ -247,7 +237,7 @@ mod alloc_mod {
|
|||||||
const STORE_FREE: PoolSize = PoolSize::MAX;
|
const STORE_FREE: PoolSize = PoolSize::MAX;
|
||||||
pub const POOL_MAX_SIZE: PoolSize = STORE_FREE - 1;
|
pub const POOL_MAX_SIZE: PoolSize = STORE_FREE - 1;
|
||||||
|
|
||||||
/// Configuration structure of the [local pool][LocalPool]
|
/// Configuration structure of the [static memory pool][StaticMemoryPool]
|
||||||
///
|
///
|
||||||
/// # Parameters
|
/// # Parameters
|
||||||
///
|
///
|
||||||
@ -341,8 +331,8 @@ mod alloc_mod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait PoolProviderWithGuards: PoolProvider {
|
pub trait PoolProviderWithGuards: PoolProvider {
|
||||||
/// This function behaves like [Self::read], but consumes the provided address and returns a
|
/// This function behaves like [PoolProvider::read], but consumes the provided address
|
||||||
/// RAII conformant guard object.
|
/// and returns a RAII conformant guard object.
|
||||||
///
|
///
|
||||||
/// Unless the guard [PoolRwGuard::release] method is called, the data for the
|
/// Unless the guard [PoolRwGuard::release] method is called, the data for the
|
||||||
/// given address will be deleted automatically when the guard is dropped.
|
/// given address will be deleted automatically when the guard is dropped.
|
||||||
@ -351,8 +341,8 @@ mod alloc_mod {
|
|||||||
/// manual deletion is necessary when returning from a processing function prematurely.
|
/// manual deletion is necessary when returning from a processing function prematurely.
|
||||||
fn read_with_guard(&mut self, addr: StoreAddr) -> PoolGuard;
|
fn read_with_guard(&mut self, addr: StoreAddr) -> PoolGuard;
|
||||||
|
|
||||||
/// This function behaves like [Self::modify], but consumes the provided address and returns a
|
/// This function behaves like [PoolProvider::modify], but consumes the provided address
|
||||||
/// RAII conformant guard object.
|
/// and returns a RAII conformant guard object.
|
||||||
///
|
///
|
||||||
/// Unless the guard [PoolRwGuard::release] method is called, the data for the
|
/// Unless the guard [PoolRwGuard::release] method is called, the data for the
|
||||||
/// given address will be deleted automatically when the guard is dropped.
|
/// given address will be deleted automatically when the guard is dropped.
|
||||||
@ -362,8 +352,18 @@ mod alloc_mod {
|
|||||||
fn modify_with_guard(&mut self, addr: StoreAddr) -> PoolRwGuard;
|
fn modify_with_guard(&mut self, addr: StoreAddr) -> PoolRwGuard;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pool implementation providing sub-pools with fixed size memory blocks. More details in
|
/// Pool implementation providing sub-pools with fixed size memory blocks.
|
||||||
/// the [module documentation][crate::pool]
|
///
|
||||||
|
/// This is a simple memory pool implementation which pre-allocates all sub-pools using a given pool
|
||||||
|
/// configuration. After the pre-allocation, no dynamic memory allocation will be performed
|
||||||
|
/// during run-time. This makes the implementation suitable for real-time applications and
|
||||||
|
/// embedded environments. The pool implementation will also track the size of the data stored
|
||||||
|
/// inside it.
|
||||||
|
///
|
||||||
|
/// Transactions with the [pool][StaticMemoryPool] are done using a generic
|
||||||
|
/// [address][StoreAddr] type.
|
||||||
|
/// Adding any data to the pool will yield a store address. Modification and read operations are
|
||||||
|
/// done using a reference to a store address. Deletion will consume the store address.
|
||||||
pub struct StaticMemoryPool {
|
pub struct StaticMemoryPool {
|
||||||
pool_cfg: StaticPoolConfig,
|
pool_cfg: StaticPoolConfig,
|
||||||
pool: Vec<Vec<u8>>,
|
pool: Vec<Vec<u8>>,
|
||||||
@ -371,8 +371,8 @@ mod alloc_mod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl StaticMemoryPool {
|
impl StaticMemoryPool {
|
||||||
/// Create a new local pool from the [given configuration][PoolCfg]. This function will sanitize
|
/// Create a new local pool from the [given configuration][StaticPoolConfig]. This function
|
||||||
/// the given configuration as well.
|
/// will sanitize the given configuration as well.
|
||||||
pub fn new(mut cfg: StaticPoolConfig) -> StaticMemoryPool {
|
pub fn new(mut cfg: StaticPoolConfig) -> StaticMemoryPool {
|
||||||
let subpools_num = cfg.sanitize();
|
let subpools_num = cfg.sanitize();
|
||||||
let mut local_pool = StaticMemoryPool {
|
let mut local_pool = StaticMemoryPool {
|
||||||
|
@ -195,8 +195,8 @@ pub trait EcssTcSenderCore: EcssChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A PUS telecommand packet can be stored in memory using different methods. Right now,
|
/// A PUS telecommand packet can be stored in memory using different methods. Right now,
|
||||||
/// storage inside a pool structure like [LocalPool], and storage inside a `Vec<u8>` are
|
/// storage inside a pool structure like [crate::pool::StaticMemoryPool], and storage inside a
|
||||||
/// supported.
|
/// `Vec<u8>` are supported.
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum TcInMemory {
|
pub enum TcInMemory {
|
||||||
|
@ -6,8 +6,8 @@ use spacepackets::ecss::{scheduling, PusPacket};
|
|||||||
use spacepackets::time::cds::TimeProvider;
|
use spacepackets::time::cds::TimeProvider;
|
||||||
|
|
||||||
/// This is a helper class for [std] environments to handle generic PUS 11 (scheduling service)
|
/// This is a helper class for [std] environments to handle generic PUS 11 (scheduling service)
|
||||||
/// packets. This handler is constrained to using the [PusScheduler], but is able to process
|
/// packets. This handler is able to handle the most important PUS requests for a scheduling
|
||||||
/// the most important PUS requests for a scheduling service.
|
/// service which provides the [PusSchedulerInterface].
|
||||||
///
|
///
|
||||||
/// Please note that this class does not do the regular periodic handling like releasing any
|
/// Please note that this class does not do the regular periodic handling like releasing any
|
||||||
/// telecommands inside the scheduler. The user can retrieve the wrapped scheduler via the
|
/// telecommands inside the scheduler. The user can retrieve the wrapped scheduler via the
|
||||||
|
Loading…
Reference in New Issue
Block a user