liminal-rs 0.16.2

A conversation-based messaging bus built on beamr
Documentation
//! The channel actor core's constructor, kept out of `mod.rs`, which holds
//! declarations only.

use std::collections::VecDeque;
use std::sync::atomic::AtomicU64;
use std::sync::{Arc, Mutex};

use beamr::atom::Atom;
use beamr::scheduler::Scheduler;

use super::{ChannelActorCore, Departures};
use crate::channel::schema::Schema;

impl ChannelActorCore {
    pub(crate) fn new(
        scheduler: Arc<Scheduler>,
        command_atom: Atom,
        schema: Schema,
        departures: Departures,
    ) -> Self {
        let scheduler_weak = Arc::downgrade(&scheduler);
        drop(scheduler);
        Self {
            scheduler: scheduler_weak,
            command_atom,
            schema: Mutex::new(schema),
            subscribers: Mutex::new(Vec::new()),
            closed: Mutex::new(false),
            commands: Mutex::new(VecDeque::new()),
            current_pid: Mutex::new(None),
            restart_lock: Mutex::new(()),
            next_command_id: AtomicU64::new(1),
            departures,
        }
    }
}