rusty_mos::memory::shared_pool

Struct MemoryPoolEntry

Source
struct MemoryPoolEntry {
    pages: Vec<usize>,
    envs: Vec<usize>,
    reference: usize,
    write_lock: AtomicUsize,
}
Expand description

Memory Pool Entry. Contains the pages it shared and the envs attatched to it. The entry also contains a lock field.

Fields§

§pages: Vec<usize>

List of page indexes shared by this pool.

§envs: Vec<usize>

List of envs bind to this pool.

§reference: usize

The reference count of this pool. Destroy the pool is the reference goes zero.

§write_lock: AtomicUsize

Write lock, store the env-id which locked it. Or zero means unlocked.

Implementations§

Source§

impl MemoryPoolEntry

Source

pub const fn new() -> Self

Create a new pool.

Source

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

Decrease the reference of the pool. If the reference is minused to zero, an Ok(true) will be returned.

Source

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

Try to lock the pool. If locked successfully, the return value is true.

Source

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

Unlock the pool. Only the env who locked it can unlock it.

§Return

If unlocked successfully, an Ok(()) is returned.

Otherwise, a KError with a Err wrapper is returned:

  • Err(KError::NoLock): The pool was not locked.
  • Err(KError::LockByOthers): The pool was locked by another env.

Trait Implementations§

Source§

impl Default for MemoryPoolEntry

Source§

fn default() -> Self

Default comstructions.

Auto Trait Implementations§

§

impl !Freeze for MemoryPoolEntry

§

impl RefUnwindSafe for MemoryPoolEntry

§

impl Send for MemoryPoolEntry

§

impl Sync for MemoryPoolEntry

§

impl Unpin for MemoryPoolEntry

§

impl UnwindSafe for MemoryPoolEntry

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.