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: AtomicU64Counter for generating unique channel IDs
recv_count: AtomicUsizeCounter for receives since last GC
gc_threshold: usizeTrigger GC after this many receives
Implementations§
Source§impl ChannelManager
impl ChannelManager
fn new() -> Self
Sourcefn create_channel(&self, capacity: usize) -> u64
fn create_channel(&self, capacity: usize) -> u64
Create a new channel and return its ID
Sourcepub(crate) fn increment_sender(&self, channel_id: u64)
pub(crate) fn increment_sender(&self, channel_id: u64)
Increment sender count for a channel
Sourcepub(crate) fn increment_receiver(&self, channel_id: u64)
pub(crate) fn increment_receiver(&self, channel_id: u64)
Increment receiver count for a channel
Sourcepub(crate) fn try_send<'ob>(
&self,
channel_id: u64,
obj: Gc<ObjectType<'ob>>,
) -> Result<(), SendError>
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)
Sourcepub(crate) fn send<'ob>(
&self,
channel_id: u64,
obj: Gc<ObjectType<'ob>>,
) -> Result<(), SendError>
pub(crate) fn send<'ob>( &self, channel_id: u64, obj: Gc<ObjectType<'ob>>, ) -> Result<(), SendError>
Send an object to a channel (blocking)
Sourcepub(crate) fn try_recv<'ob>(
&self,
channel_id: u64,
target_block: &'ob Block<false>,
) -> Result<Gc<ObjectType<'ob>>, RecvError>
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)
Sourcepub(crate) fn recv<'ob>(
&self,
channel_id: u64,
target_block: &'ob Block<false>,
) -> Result<Gc<ObjectType<'ob>>, RecvError>
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)
Sourcepub(crate) fn close_sender(&self, channel_id: u64)
pub(crate) fn close_sender(&self, channel_id: u64)
Close the sender side of a channel
Sourcepub(crate) fn close_receiver(&self, channel_id: u64)
pub(crate) fn close_receiver(&self, channel_id: u64)
Close the receiver side of a channel
Sourcefn collect_garbage(&self)
fn collect_garbage(&self)
Trigger garbage collection in the manager’s block
Sourcepub(crate) fn cleanup_channel(&self, channel_id: u64)
pub(crate) fn cleanup_channel(&self, channel_id: u64)
Remove a channel that has no more senders or receivers