mod.rs

Overview

This file implements a service responsible for tracking updates to a threads table in the context of block finalization within a system managing concurrent or parallel thread execution. Specifically, it monitors the creation and destruction of threads as blocks become finalized and notifies subscribers of such events. The service assumes that blocks are finalized in the correct order and provides mechanisms to initialize thread tracking, handle block finalization, and notify subscribers about thread lifecycle events.

The main entities in this file are:

Entities and Components

CheckpointBlockData

A data structure containing information about a block and its relation to threads.

Fields

CommandError

An enumeration of error types that can occur during command processing in the ThreadsTrackingService.

Variants

ThreadsTrackingService

This struct implements the thread tracking logic.

Methods

Subscriber Trait (from subscribers module)

Defines the interface for receiving notifications about thread start and stop events.

See the subscribers module for detailed implementation and usage of Subscriber.

Important Implementation Details and Algorithms

Interaction with Other Parts of the System

Visual Diagram

classDiagram
class ThreadsTrackingService {
+start()
+init_thread()
+handle_block_invalidated()
+handle_block_finalized()
}
class CheckpointBlockData {
+parent_block_identifier
+block_identifier
+thread_identifier
+threads_table
}
class CommandError {
<<enum>>
+BlockDataMissing
+UnexpectedDependency
+ParentBlockMissing
+CriticalInconsistency
}
ThreadsTrackingService ..> CommandError : uses
ThreadsTrackingService ..> CheckpointBlockData : uses
ThreadsTrackingService ..> Subscriber : notifies
Subscriber <|.. subscribers::Subscriber

This diagram shows the main structs and their relationships within this file: the ThreadsTrackingService manages thread lifecycle tracking and notifies the Subscriber trait implementations; it uses CheckpointBlockData for block metadata and returns or handles CommandError variants when applicable.