pub struct SharedCompletedNodes { /* private fields */ }
Expand description
A concurrency‐safe set of completed node indices, using tokio::sync::AsyncMutex<HashSet<usize>>
.
Implementations§
Sourcepub fn from_slice(nodes: &[usize]) -> Self
pub fn from_slice(nodes: &[usize]) -> Self
Constructs a SharedCompletedNodes
by inserting all elements from the given slice.
Duplicates in the slice are ignored (only one copy of each index is stored).
Sourcepub async fn insert(
&self,
node_idx: usize,
) -> Result<InsertOutcome, NetworkError>
pub async fn insert( &self, node_idx: usize, ) -> Result<InsertOutcome, NetworkError>
Inserts node_idx
into the set. Returns InsertOutcome
or a potential NetworkError
.
Sourcepub async fn clear(&self) -> usize
pub async fn clear(&self) -> usize
Clears all entries. Returns the number of entries that were cleared.
Sourcepub async fn is_all_done(&self, total_count: usize) -> bool
pub async fn is_all_done(&self, total_count: usize) -> bool
Returns true
if we have exactly total_count
unique nodes in the set.
Sourcepub async fn as_slice(&self) -> Vec<usize>
pub async fn as_slice(&self) -> Vec<usize>
Returns a sorted snapshot (as a Vec<usize>
) of the current contents.
Sourcepub async fn mark_node_completed(
&self,
node_idx: usize,
worker_id: usize,
checkpoint_cb: Option<Arc<dyn CheckpointCallback>>,
)
pub async fn mark_node_completed( &self, node_idx: usize, worker_id: usize, checkpoint_cb: Option<Arc<dyn CheckpointCallback>>, )
Marks node_idx
as completed, logs the outcome, and optionally calls a checkpoint callback.
§Arguments
node_idx
: The index to record.worker_id
: For logging; e.g. which worker thread is marking completion.checkpoint_cb
: Optionally, a callback to be invoked with a sorted snapshot of the set.
Trait Implementations§
Source§fn clone(&self) -> SharedCompletedNodes
fn clone(&self) -> SharedCompletedNodes
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more