WaitingStrategy

Trait WaitingStrategy 

Source
pub trait WaitingStrategy:
    Default
    + Send
    + Sync {
    // Required methods
    fn new() -> Self;
    fn wait_for<F: Fn() -> bool>(
        &self,
        sequence: Sequence,
        dependencies: &[Arc<AtomicSequence>],
        check_alert: F,
    ) -> Option<i64>;
    fn signal_all_when_blocking(&self);
}
Expand description

Defines how threads wait for available sequences.

Implements the strategy pattern for different waiting behaviors when sequences are not yet available.

§Examples

use disruptor_rs::traits::WaitingStrategy;
use disruptor_rs::sequence::AtomicSequence;

#[derive(Default)]
struct BlockingWaitStrategy;

impl WaitingStrategy for BlockingWaitStrategy {
    fn new() -> Self {
        BlockingWaitStrategy
    }

    fn wait_for<F: Fn() -> bool>(
        &self,
        sequence: i64,
        dependencies: &[std::sync::Arc<AtomicSequence>],
        check_alert: F
    ) -> Option<i64> {
        // Implementation would go here
        None
    }

    fn signal_all_when_blocking(&self) {
        // Implementation would go here
    }
}

§Methods

  • new - Creates a new instance of the waiting strategy
  • wait_for - Waits for the given sequence to be available
  • signal_all_when_blocking - Signals that all threads should be blocked

Required Methods§

Source

fn new() -> Self

Source

fn wait_for<F: Fn() -> bool>( &self, sequence: Sequence, dependencies: &[Arc<AtomicSequence>], check_alert: F, ) -> Option<i64>

Source

fn signal_all_when_blocking(&self)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§