Skip to main content

System

Struct System 

Source
pub struct System(/* private fields */);
Expand description

Runtime manager for a group of arbiter threads.

A system stores runtime configuration, manages arbiters, dispatches process signals, and owns the blocking thread pool.

Implementations§

Source§

impl System

Source

pub fn build() -> Builder

Creates a builder for a system with a customized runtime.

See Builder for the available configuration options.

Source

pub fn new<R: Runner>(name: &str, runner: R) -> SystemRunner

Creates a system runner with the specified name and runtime runner.

§Panics

Panics if the runtime cannot be created.

Source

pub fn with_config(name: &str, config: SystemConfig) -> SystemRunner

Creates a system runner from an existing configuration.

§Panics

Panics if the runtime cannot be created.

Source

pub fn current() -> System

Returns the system running on the current thread.

§Panics

Panics if no system is running on the current thread.

Source

pub fn try_current() -> Option<System>

Returns the system running on the current thread, if one exists.

Source

pub fn id(&self) -> Id

Returns the system identifier.

Source

pub fn name(&self) -> &str

Returns the system name.

Source

pub fn stop(&self)

Stops the system with exit code 0.

Source

pub fn stop_with_code(&self, code: i32)

Stops the system with the specified exit code.

Source

pub fn signals(&self) -> bool

Returns whether process signal handling is enabled.

Source

pub fn enable_signals(&self)

Enables process signal handling.

Source

pub fn disable_signals(&self)

Disables process signal handling.

Source

pub fn arbiter(&self) -> Arbiter

Returns the system’s primary arbiter.

§Panics

Panics if the system has not been started.

Source

pub fn list_arbiters<F, R>(&self, f: F) -> R
where F: FnOnce(&[Arbiter]) -> R,

Provides access to all arbiters registered with this system.

This method should be called from the thread where the system has been initialized, typically the “main” thread.

Source

pub fn list_arbiter_pings<F>(f: F)
where F: FnMut(&Arbiter, &mut VecDeque<PingRecord>),

Visits the latest ping records for each registered arbiter.

This method should be called from the thread where the system has been initialized, typically the “main” thread.

Source

pub fn config(&self) -> SystemConfig

Returns a clone of the system configuration.

Source

pub fn handle(&self) -> Handle

Returns a runtime handle for the primary arbiter.

Source

pub fn testing(&self) -> bool

Returns whether the system is configured for testing.

Source

pub fn spawn_blocking<F, R>(&self, f: F) -> BlockingResult<R>
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,

Spawns a blocking task on a new thread and waits for it to complete.

Dropping the returned future prevents queued work from starting, but cannot interrupt work that is already running. Call BlockingResult::detach to let queued work continue even if its result is no longer needed.

Source

pub fn get_value<T>(&self, f: impl FnOnce() -> T) -> T
where T: Clone + Send + Sync + 'static,

Returns a previously registered type, or inserts and returns a new one.

This method acquires a lock on the internal data structure. To avoid repeated locking, prefer storing a cloned value in the arbiter’s storage.

Trait Implementations§

Source§

impl Clone for System

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for System

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.