Skip to main content

System

Struct System 

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

System is a runtime manager

Implementations§

Source§

impl System

Source

pub fn build() -> Builder

Build a new system with a customized runtime

This allows to customize the runtime. See struct level docs on Builder for more information.

Source

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

Create new system

This method panics if it can not create runtime

Source

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

Create new system

This method panics if it can not create runtime

Source

pub fn current() -> System

Get current running system

§Panics

Panics if System is not running

Source

pub fn try_current() -> Option<System>

Runs a function using the system context.

Source

pub fn id(&self) -> Id

System id

Source

pub fn name(&self) -> &str

System name

Source

pub fn stop(&self)

Stop the system

Source

pub fn stop_with_code(&self, code: i32)

Stop the system with a particular exit code

Source

pub fn signals(&self) -> bool

Return status of signals option

Source

pub fn enable_signals(&self)

Enable signals handling

Source

pub fn disable_signals(&self)

Disable signals handling

Source

pub fn arbiter(&self) -> Arbiter

System arbiter

§Panics

Panics if system is not started

Source

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

Retrieves a list of all arbiters in the 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>),

Retrieves a list of last pings records for each worker.

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

Source

pub fn config(&self) -> SystemConfig

System config

Source

pub fn handle(&self) -> Handle

Runtime handle for main thread

Source

pub fn testing(&self) -> bool

Testing flag

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.

If the returned future is dropped, the blocking task is cancelled. Call detach to allow the task to continue running in the background.

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 = 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.