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
impl MemoryPool
Sourcepub fn crate_pool(&mut self, envid: usize) -> usize
pub fn crate_pool(&mut self, envid: usize) -> usize
Get a new pool id and create a new pool entry.
Sourcepub fn insert_page(
&mut self,
poolid: usize,
pageid: usize,
) -> Result<(), KError>
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.
Sourcepub fn fork_bind(&mut self, child_id: usize, envid: usize)
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.
Sourcepub fn bind(
&mut self,
poolid: usize,
envid: usize,
) -> Result<&Vec<usize>, KError>
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.
Sourcefn unbind(&mut self, poolid: usize, envid: usize) -> Result<(), KError>
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.
Sourcepub fn destory_env(&mut self, envid: usize)
pub fn destory_env(&mut self, envid: usize)
Unbind all the pools bind to the env. Called by env_free.