Skip to main content

MultiCoreEngine

Struct MultiCoreEngine 

Source
pub struct MultiCoreEngine<F: FileSystem = TokioFileSystem> { /* private fields */ }
Expand description

Builder for a multi-core actor engine.

Each core runs an independent current_thread Tokio runtime (optionally pinned to a physical CPU). All cores share a single InProcessTransport so cross-core sends work transparently: a message from core 0 to an actor on core 1 is pushed directly into that actor’s Tokio mpsc mailbox, which the receiving core’s task wakes up to process.

§Example

use palladium_runtime::{MultiCoreEngine, EngineConfig};
use palladium_actor::ChildSpec;
use palladium_runtime::Placement;

let mut engine = MultiCoreEngine::new(2);
// engine.add_user_actor(spec, Placement::Core(0));
let handle = engine.start().unwrap();
handle.shutdown().unwrap();

Implementations§

Source§

impl MultiCoreEngine<TokioFileSystem>

Source

pub fn new(num_cores: usize) -> Self

Create a new engine with num_cores cores and default config.

Source

pub fn with_config(config: EngineConfig<TokioReactor>) -> Self

Create a new engine from an EngineConfig.

num_cores is taken from config.num_cores, falling back to std::thread::available_parallelism().

Source§

impl<F: FileSystem> MultiCoreEngine<F>

Source

pub fn with_fs(config: EngineConfig<TokioReactor>, fs: F) -> Self

Create a new engine with a specific filesystem.

Source

pub fn add_user_actor( &mut self, spec: ChildSpec<TokioReactor>, placement: Placement, )

Register an actor to be spawned at startup on a specific core.

Pre-populates the placement map so cross-core routing is immediately available once the engine starts.

Source

pub fn start(self) -> Result<MultiCoreHandle<F>, EngineError>

Start the engine: spawn N threads, each running a Tokio runtime.

Returns a MultiCoreHandle immediately — actors are started asynchronously inside the spawned threads. Use MultiCoreHandle::wait_for_actor to synchronise before sending.

If EngineConfig::control_plane_socket is set, a [ControlPlaneActor] is added to core 0’s user supervisor so the engine can be managed via pd status, pd actor, and pd stop.

Auto Trait Implementations§

§

impl<F> Freeze for MultiCoreEngine<F>
where F: Freeze,

§

impl<F = TokioFileSystem> !RefUnwindSafe for MultiCoreEngine<F>

§

impl<F> Send for MultiCoreEngine<F>

§

impl<F> Sync for MultiCoreEngine<F>

§

impl<F> Unpin for MultiCoreEngine<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for MultiCoreEngine<F>
where F: UnsafeUnpin,

§

impl<F = TokioFileSystem> !UnwindSafe for MultiCoreEngine<F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> Upcast<T> for U
where T: UpcastFrom<U>,

Source§

fn upcast(self) -> T

Source§

impl<T, B> UpcastFrom<Counter<T, B>> for T

Source§

fn upcast_from(value: Counter<T, B>) -> T

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V