Settings
Help

ChannelManager

Struct ChannelManager 

Source
pub(crate) struct ChannelManager {
    gc_state: Mutex<GcState>,
    gc_access: RwLock<()>,
    channels: RwLock<HashMap<u64, Arc<ChannelState>>>,
    next_channel_id: AtomicU64,
    recv_count: AtomicUsize,
    gc_threshold: usize,
}
Expand description

The channel manager state

Fields§

§gc_state: Mutex<GcState>

GC state (block, roots, and next_limit) all guarded by a single Mutex We also leak a static reference to the RootSet for HeapRoot creation

§gc_access: RwLock<()>

Ensures mutual exclusion between GC and channel operations. Channel operations acquire read lock when accessing rooted data, GC acquires write lock for exclusive access during trace.

§channels: RwLock<HashMap<u64, Arc<ChannelState>>>

All channels managed by this manager

§next_channel_id: AtomicU64

Counter for generating unique channel IDs

§recv_count: AtomicUsize

Counter for receives since last GC

§gc_threshold: usize

Trigger GC after this many receives

Implementations§

Source§

impl ChannelManager

Source

fn new() -> Self

Source

fn create_channel(&self, capacity: usize) -> u64

Create a new channel and return its ID

Source

pub(crate) fn increment_sender(&self, channel_id: u64)

Increment sender count for a channel

Source

pub(crate) fn increment_receiver(&self, channel_id: u64)

Increment receiver count for a channel

Source

pub(crate) fn try_send<'ob>( &self, channel_id: u64, obj: Gc<ObjectType<'ob>>, ) -> Result<(), SendError>

Try to send an object to a channel (non-blocking)

Source

pub(crate) fn send<'ob>( &self, channel_id: u64, obj: Gc<ObjectType<'ob>>, ) -> Result<(), SendError>

Send an object to a channel (blocking)

Source

pub(crate) fn try_recv<'ob>( &self, channel_id: u64, target_block: &'ob Block<false>, ) -> Result<Gc<ObjectType<'ob>>, RecvError>

Try to receive an object from a channel (non-blocking)

Source

pub(crate) fn recv<'ob>( &self, channel_id: u64, target_block: &'ob Block<false>, ) -> Result<Gc<ObjectType<'ob>>, RecvError>

Receive an object from a channel (blocking)

Source

pub(crate) fn close_sender(&self, channel_id: u64)

Close the sender side of a channel

Source

pub(crate) fn close_receiver(&self, channel_id: u64)

Close the receiver side of a channel

Source

fn collect_garbage(&self)

Trigger garbage collection in the manager’s block

Source

pub(crate) fn cleanup_channel(&self, channel_id: u64)

Remove a channel that has no more senders or receivers

Source§

impl ChannelManager

Source

pub(crate) fn new_channel_pair(&self, capacity: usize) -> (u64, u64)

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V