rusty_mos::memory::shared_pool

Struct MemoryPool

Source
pub struct MemoryPool {
    pools: BTreeMap<usize, MemoryPoolEntry>,
    envs: BTreeMap<usize, Vec<usize>>,
}
Expand description

Memory pool manager. Support every operation that is needed to perform.

Fields§

§pools: BTreeMap<usize, MemoryPoolEntry>

The memory pools. Map from pool_id to MemoryPoolEntry.

§envs: BTreeMap<usize, Vec<usize>>

Implementations§

Source§

impl MemoryPool

Source

pub const fn new() -> Self

Create a new pool manager.

Source

pub fn crate_pool(&mut self, envid: usize) -> usize

Get a new pool id and create a new pool entry.

Source

pub fn insert_page( &mut self, poolid: usize, pageid: usize, ) -> Result<(), KError>

Insert a page into a pool. If the pool is not found, a Err(KError::PoolNotFound) will be returned.

Source

pub fn fork_bind(&mut self, child_id: usize, envid: usize)

Bind the forked child env into the parent env’s pools.

Since when forked, the parent’s pages will be dupped to the child’s, so we need to fork the pools meanwhile. The reference of each pool will be increased.

Source

pub fn bind( &mut self, poolid: usize, envid: usize, ) -> Result<&Vec<usize>, KError>

Bind bind an env to a pool. If the pool does not exist or the env has been bind to the pool, This method will fail.

Source

fn unbind(&mut self, poolid: usize, envid: usize) -> Result<(), KError>

Unbind an env from a pool. If unbind successfully, the pool will get a decrease-reference.

Source

pub fn destory_env(&mut self, envid: usize)

Unbind all the pools bind to the env. Called by env_free.

Source

pub fn lock(&mut self, poolid: usize, envid: usize) -> Result<bool, KError>

Lock the pool with poolid, and the locker will be envid.

Source

pub fn unlock(&mut self, poolid: usize, envid: usize) -> Result<(), KError>

Unlock the pool with poolid, and the locker will be envid.

Trait Implementations§

Source§

impl Default for MemoryPool

Source§

fn default() -> Self

Default constructions

Auto Trait Implementations§

§

impl Freeze for MemoryPool

§

impl RefUnwindSafe for MemoryPool

§

impl Send for MemoryPool

§

impl Sync for MemoryPool

§

impl Unpin for MemoryPool

§

impl UnwindSafe for MemoryPool

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.