moirai_executor/schedule/route/decision.rs
1//! Concrete scheduler route decisions.
2
3use super::{AcceleratorId, AcceleratorKind, AsyncLaneId, ProcessId, ServerId, ThreadId};
4
5/// Local thread route.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub struct ThreadRoute {
8 /// Target process containing the thread.
9 pub process: ProcessId,
10 /// Target local scheduler thread.
11 pub thread: ThreadId,
12}
13
14/// Process route with an optional async lane.
15#[derive(Debug, Clone, Copy, PartialEq, Eq)]
16pub struct ProcessRoute {
17 /// Target process.
18 pub process: ProcessId,
19 /// Target scheduler thread inside the process.
20 pub thread: ThreadId,
21 /// Target async lane for async-capable work.
22 pub async_lane: Option<AsyncLaneId>,
23}
24
25/// Server route with process, thread, and optional async-lane placement.
26#[derive(Debug, Clone, Copy, PartialEq, Eq)]
27pub struct ServerRoute {
28 /// Target server.
29 pub server: ServerId,
30 /// Target process on the server.
31 pub process: ProcessId,
32 /// Target scheduler thread inside the process.
33 pub thread: ThreadId,
34 /// Target async lane for async-capable work.
35 pub async_lane: Option<AsyncLaneId>,
36}
37
38/// Accelerator placement metadata.
39#[derive(Debug, Clone, Copy, PartialEq, Eq)]
40pub struct AcceleratorRoute {
41 /// Target accelerator family.
42 pub kind: AcceleratorKind,
43 /// Target accelerator within the family.
44 pub accelerator: AcceleratorId,
45 /// Target process coordinating the device placement.
46 pub process: ProcessId,
47 /// Target scheduler thread coordinating the device placement.
48 pub thread: ThreadId,
49 /// Target async lane for async-capable accelerator work.
50 pub async_lane: Option<AsyncLaneId>,
51}
52
53/// Concrete route decision produced by [`super::HybridRouter`].
54#[derive(Debug, Clone, Copy, PartialEq, Eq)]
55pub enum SchedulerRoute {
56 /// Route remains inside the local scheduler worker set.
57 Thread(ThreadRoute),
58 /// Route crosses a process boundary.
59 Process(ProcessRoute),
60 /// Route crosses a server boundary.
61 Server(ServerRoute),
62 /// Route targets accelerator placement metadata.
63 Accelerator(AcceleratorRoute),
64}