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>
impl MultiCoreEngine<TokioFileSystem>
Sourcepub fn new(num_cores: usize) -> Self
pub fn new(num_cores: usize) -> Self
Create a new engine with num_cores cores and default config.
Sourcepub fn with_config(config: EngineConfig<TokioReactor>) -> Self
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>
impl<F: FileSystem> MultiCoreEngine<F>
Sourcepub fn with_fs(config: EngineConfig<TokioReactor>, fs: F) -> Self
pub fn with_fs(config: EngineConfig<TokioReactor>, fs: F) -> Self
Create a new engine with a specific filesystem.
Sourcepub fn add_user_actor(
&mut self,
spec: ChildSpec<TokioReactor>,
placement: Placement,
)
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.
Sourcepub fn start(self) -> Result<MultiCoreHandle<F>, EngineError>
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.