Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
14625de
Add dynamic child process startup
wdcui Sep 17, 2026
774c402
Clarify child process state and commit naming
wdcui Sep 17, 2026
b242864
Unify child process negotiation
wdcui Sep 17, 2026
25be3a9
Complete child process startup lifecycle
wdcui Sep 18, 2026
7e9f4ab
Unify runner process observation
wdcui Sep 18, 2026
afe4b91
Model child startup in process state
wdcui Sep 18, 2026
f40e3df
Simplify process lifecycle cleanup
wdcui Sep 18, 2026
4e3bc45
Simplify broker host request plumbing
wdcui Sep 18, 2026
f4019c4
Unify runner startup negotiation
wdcui Sep 18, 2026
1ca51c4
Simplify startup protocol and pending calls
wdcui Sep 18, 2026
3c5ed9a
Unify runner process model
wdcui Sep 18, 2026
063297e
Clarify runner process manager naming
wdcui Sep 18, 2026
336c0fb
Simplify runner process startup
wdcui Sep 18, 2026
cd9bdfc
Simplify runner startup negotiation
wdcui Sep 19, 2026
00745bb
Unify runner process creation
wdcui Sep 19, 2026
e69d190
Unify process startup activation
wdcui Sep 19, 2026
9b190e5
Fix negotiated thread quota test
wdcui Sep 19, 2026
0d730fb
Centralize shared buffer sequence copies
wdcui Sep 19, 2026
e27c4dd
Simplify broker local process API
wdcui Sep 19, 2026
901c000
Clarify child process start operation
wdcui Sep 19, 2026
ba8e675
Clarify process identity result
wdcui Sep 19, 2026
cc4aa67
Centralize broker process lifecycle
wdcui Sep 19, 2026
c8cee55
Remove redundant process lifecycle coordination
wdcui Sep 19, 2026
f887899
Extract process launcher provider
wdcui Sep 19, 2026
33beec7
Move process launcher out of runner module
wdcui Sep 19, 2026
ed3cdc9
Remove broker userland platform dependencies
wdcui Sep 19, 2026
d6cf33b
Require negotiated initial thread for Linux load
wdcui Sep 19, 2026
4717d1a
Unify root and child process launch
wdcui Sep 20, 2026
483a469
Preserve root runner startup errors
wdcui Sep 20, 2026
a61d3d1
Fix macOS broker negotiation test
wdcui Sep 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 40 additions & 5 deletions litebox/src/litebox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use alloc::sync::Arc;

use litebox_broker_local::BrokerLocal;
use litebox_broker_protocol::ProcessId;
use litebox_broker_protocol::message::BrokerNotification;
use litebox_broker_transport::channel::LocalCallChannel;
use litebox_platform::time::TimeProvider;
Expand All @@ -14,6 +15,7 @@ use crate::{
broker,
fd::Descriptors,
sync::{RawSyncPrimitivesProvider, RwLock},
thread::Thread,
};

/// A full LiteBox system.
Expand Down Expand Up @@ -48,16 +50,49 @@ impl<Platform: RawSyncPrimitivesProvider> LiteBox<Platform> {
platform: &'static Platform,
broker_local: BrokerLocal<Channel>,
) -> Self
where
Platform: TimeProvider,
Channel: LocalCallChannel + Send + Sync + 'static,
{
Self::new_with_broker_local_inner(platform, broker_local).0
}

fn new_with_broker_local_inner<Channel>(
platform: &'static Platform,
broker_local: BrokerLocal<Channel>,
) -> (Self, Arc<dyn broker::BrokerControl>)
where
Platform: TimeProvider,
Channel: LocalCallChannel + Send + Sync + 'static,
{
let broker_pollables = Arc::new(broker::BrokerPollableRegistry::new());
let broker_control = Arc::new(broker::BrokerLocalControl::<Platform, Channel>::new(
broker_local,
Arc::clone(&broker_pollables),
));
Self::new_inner(platform, Some(broker_control), broker_pollables)
let broker_control: Arc<dyn broker::BrokerControl> =
Arc::new(broker::BrokerLocalControl::<Platform, Channel>::new(
broker_local,
Arc::clone(&broker_pollables),
));
let litebox = Self::new_inner(
platform,
Some(Arc::clone(&broker_control)),
broker_pollables,
);
(litebox, broker_control)
}

/// Creates a broker-backed process and its negotiated initial thread.
pub fn new_process_with_broker_local<Channel>(
platform: &'static Platform,
broker_local: BrokerLocal<Channel>,
) -> (Self, ProcessId, Thread)
where
Platform: TimeProvider,
Channel: LocalCallChannel + Send + Sync + 'static,
{
let process_id = broker_local.process_id();
let initial_thread_id = broker_local.initial_thread_id();
let (litebox, broker) = Self::new_with_broker_local_inner(platform, broker_local);
let initial_thread = Thread::from_broker(initial_thread_id, broker);
(litebox, process_id, initial_thread)
}

fn new_inner(
Expand Down
4 changes: 4 additions & 0 deletions litebox/src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ pub struct Thread {
}

impl Thread {
pub(crate) fn from_broker(id: ThreadId, broker: Arc<dyn BrokerControl>) -> Self {
Self { id, broker }
}

/// Returns the assigned thread ID.
#[must_use]
pub const fn id(&self) -> u32 {
Expand Down
29 changes: 27 additions & 2 deletions litebox_broker_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub use policy::{
use process::ObjectReference;
pub use process::{
AssociationCancellation, BrokerProcess, BrokerThread, CallerCredential, ObjectRights,
ProcessLifecycleSink, ProcessShutdown,
};
use random::RandomProvider;
use socket::{BrokerSocketPorts, SocketProvider};
Expand Down Expand Up @@ -213,10 +214,17 @@ pub struct BrokerCore {
pub(crate) socket_provider: Arc<dyn SocketProvider>,
pub(crate) fs: Arc<dyn FileService>,
pub(crate) socket_ports: BrokerSocketPorts,
pub(crate) process_lifecycle_sink: Arc<dyn ProcessLifecycleSink>,
}

static BROKER_CORE_CREATED: AtomicBool = AtomicBool::new(false);

struct NoopProcessLifecycleSink;

impl ProcessLifecycleSink for NoopProcessLifecycleSink {
fn changed(&self) {}
}

impl BrokerCore {
/// Creates the broker core with broker-wide service providers.
pub fn new(
Expand Down Expand Up @@ -266,9 +274,25 @@ impl BrokerCore {
socket_provider,
fs,
socket_ports: BrokerSocketPorts::default(),
process_lifecycle_sink: Arc::new(NoopProcessLifecycleSink),
})
}

/// Returns a broker handle that publishes process lifecycle changes to `sink`.
#[must_use]
pub fn with_process_lifecycle_sink(&self, sink: Arc<dyn ProcessLifecycleSink>) -> Self {
Self {
process_lifecycle_sink: sink,
..self.clone()
}
}

/// Returns whether any broker process remains registered.
#[must_use]
pub fn has_processes(&self) -> bool {
!self.processes.read().is_empty()
}

/// Returns the configured authority-state limits.
#[must_use]
pub const fn limits(&self) -> BrokerCoreLimits {
Expand Down Expand Up @@ -301,7 +325,7 @@ impl BrokerCore {
Ok((first, second))
}

/// Allocates and registers one authenticated broker process.
/// Allocates one authenticated process awaiting association activation.
///
/// # Panics
///
Expand All @@ -310,6 +334,7 @@ impl BrokerCore {
pub fn create_process(
&self,
caller_credential: CallerCredential,
parent_id: Option<ProcessId>,
) -> Result<Arc<BrokerProcess>> {
let mut processes = self.processes.write();
if processes.len() >= self.limits.max_processes {
Expand All @@ -323,7 +348,7 @@ impl BrokerCore {
let process = Arc::new(BrokerProcess::new(
self.clone(),
id,
None,
parent_id,
caller_credential,
));
assert!(
Expand Down
Loading
Loading