Skip to main content

Component

Struct Component 

Source
pub struct Component<CD>
where CD: ComponentTraits,
{ /* private fields */ }
Expand description

A concrete component instance

The component class itself is application agnostic, but it contains the application specific ComponentDefinition.

Implementations§

Source§

impl<CD> Component<CD>
where CD: ComponentTraits,

Source

pub fn definition_mut(&mut self) -> &mut CD

Returns a mutable reference to the underlying component definition.

This can only be done if you have a reference to the component instance that isn’t hidden behind an Arc. For example, after the system shuts down and your code holds on to the last reference to a component you can use get_mut or try_unwrap.

Source

pub fn on_definition<T, F>(&self, f: F) -> T
where F: FnOnce(&mut CD) -> T,

Execute a function on the underlying ComponentDefinition and return the result

This method will attempt to lock the mutex, and then apply f to the component definition inside the guard.

Source

pub fn logger(&self) -> &Logger<Arc<Fuse<Async>>>

Returns a reference to this component’s logger

Source

pub fn is_faulty(&self) -> bool

Returns true if the component is marked as faulty.

Source

pub fn is_active(&self) -> bool

Returns true if the component is marked as active.

Source

pub fn is_destroyed(&self) -> bool

Returns true if the component is marked as destroyed.

Source

pub fn wait_ended(&self)

Wait synchronously for this component be either destroyed or faulty

This component blocks the current thread and hot-waits for the component to become either faulty or destroyed. It is meant mostly for testing and not recommended in production.

Source

pub fn set_recovery_function<F>(&self, f: F)
where F: FnOnce(FaultContext) -> RecoveryHandler + Send + 'static,

Set the recovery function for this component

See RecoveryHandler for more information.

Trait Implementations§

Source§

impl<C> AbstractComponent for Component<C>

Source§

fn dyn_definition_mut( &mut self, ) -> &mut dyn DynamicComponentDefinition<Message = <Component<C> as MsgQueueContainer>::Message>

Returns a mutable reference to the underlying component definition as a DynamicComponentDefinition trait object. Read more
Source§

fn lock_dyn_definition( &self, ) -> Result<OwningRefMut<Box<dyn Erased + '_>, dyn DynamicComponentDefinition<Message = <Component<C> as MsgQueueContainer>::Message>>, LockPoisoned>

Locks the component definition mutex and returns a guard that can be dereferenced to access a DynamicComponentDefinition trait object.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Views self as Any. Can be used to downcast to a concrete Component.
Source§

fn as_queue_container( self: Arc<Component<C>>, ) -> Weak<dyn MsgQueueContainer<Message = <Component<C> as MsgQueueContainer>::Message>>

Upcast this Read more
Source§

impl<CD> ArcWake for Component<CD>

Source§

fn wake_by_ref(arc_self: &Arc<Component<CD>>)

Indicates that the associated task is ready to make progress and should be polled. Read more
Source§

fn wake(self: Arc<Self>)

Indicates that the associated task is ready to make progress and should be polled. Read more
Source§

impl<CD> CoreContainer for Component<CD>
where CD: ComponentTraits,

Source§

fn id(&self) -> Uuid

Returns the component’s unique id
Source§

fn core(&self) -> &ComponentCore

Returns a reference to the actual component core
Source§

fn execute(&self) -> SchedulingDecision

Executes this component on the current thread
Source§

fn schedule(&self)

Schedules this component on its associated scheduler
Source§

fn type_name(&self) -> &'static str

The descriptive string of the ComponentDefinition type wrapped in this container
Source§

fn dyn_message_queue(&self) -> &dyn DynMsgQueue

Returns the underlying message queue of this component without the type information
Source§

fn enqueue_control(&self, event: ControlEvent)

Enqueue an event on the component’s control queue Read more
Source§

fn system(&self) -> &KompactSystem

Returns this component’s system
Source§

impl<CD> Debug for Component<CD>
where CD: ComponentTraits,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<CD> MsgQueueContainer for Component<CD>
where CD: ComponentTraits,

Source§

type Message = <CD as ActorRaw>::Message

The message type of the queue
Source§

fn message_queue( &self, ) -> &TypedMsgQueue<<Component<CD> as MsgQueueContainer>::Message>

The actual underlying queue
Source§

fn downgrade_dyn(self: Arc<Component<CD>>) -> Weak<dyn CoreContainer>

A weak reference to the component that must be scheduled when something is enqueued

Auto Trait Implementations§

§

impl<CD> !Freeze for Component<CD>

§

impl<CD> !RefUnwindSafe for Component<CD>

§

impl<CD> Send for Component<CD>

§

impl<CD> Sync for Component<CD>

§

impl<CD> Unpin for Component<CD>
where CD: Unpin, <CD as ActorRaw>::Message: Unpin,

§

impl<CD> UnsafeUnpin for Component<CD>
where CD: UnsafeUnpin,

§

impl<CD> !UnwindSafe for Component<CD>

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> DispatchEvent for T
where T: Any + Send + Debug,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any + Send>

Convert this event into an erased Any payload for downcasting.
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Erased for T

Source§

impl<M> MessageBounds for M
where M: Debug + Send + 'static,