Search Results for

    Show / Hide Table of Contents

    Class ActorCell

    INTERNAL API.

    The hosting infrastructure for actors.

    Inheritance
    object
    ActorCell
    InternalTestActorRef.TestActorCell
    Implements
    IUntypedActorContext
    IActorContext
    IActorRefFactory
    ICanWatch
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Akka.Actor
    Assembly: Akka.dll
    Syntax
    public class ActorCell : IUntypedActorContext, IActorContext, IActorRefFactory, ICanWatch

    Constructors

    | Edit this page View Source

    ActorCell(ActorSystemImpl, IInternalActorRef, Props, MessageDispatcher, IInternalActorRef)

    TBD

    Declaration
    public ActorCell(ActorSystemImpl system, IInternalActorRef self, Props props, MessageDispatcher dispatcher, IInternalActorRef parent)
    Parameters
    Type Name Description
    ActorSystemImpl system

    TBD

    IInternalActorRef self

    TBD

    Props props

    TBD

    MessageDispatcher dispatcher

    TBD

    IInternalActorRef parent

    TBD

    Fields

    | Edit this page View Source

    UndefinedUid

    Constant placeholder value for actors without a defined unique identifier.

    Declaration
    public const int UndefinedUid = 0
    Field Value
    Type Description
    int

    Properties

    | Edit this page View Source

    ChildrenContainer

    The child container collection, used to house information about all child actors.

    Declaration
    public IChildrenContainer ChildrenContainer { get; }
    Property Value
    Type Description
    IChildrenContainer
    | Edit this page View Source

    CurrentEnvelopeId

    INTERNAL API

    Declaration
    public int CurrentEnvelopeId { get; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    CurrentMessage

    The current message the actor is processing right now.

    Declaration
    public object? CurrentMessage { get; }
    Property Value
    Type Description
    object
    Remarks

    Will be set to null when not processing any message.

    | Edit this page View Source

    Dispatcher

    This actor's message dispatcher.

    Declaration
    public MessageDispatcher Dispatcher { get; }
    Property Value
    Type Description
    MessageDispatcher
    | Edit this page View Source

    HasMessages

    Will return true if NumberOfMessages is greater than zero.

    Declaration
    public bool HasMessages { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    IsLocal

    Returns true if this actor is local to the system. Can only return false if this actor is remotely deployed from elsewhere.

    Declaration
    public bool IsLocal { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    IsNormal

    Declaration
    protected bool IsNormal { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    IsTerminated

    Indicates whether the actor is currently terminated.

    Declaration
    public bool IsTerminated { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    IsTerminating

    Declaration
    protected bool IsTerminating { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    Mailbox

    This actor's mailbox instance.

    Declaration
    public Mailbox? Mailbox { get; }
    Property Value
    Type Description
    Mailbox
    | Edit this page View Source

    NumberOfMessages

    Current message count inside the mailbox.

    Declaration
    public int NumberOfMessages { get; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    Parent

    This actor's parent actor.

    Declaration
    public IInternalActorRef Parent { get; }
    Property Value
    Type Description
    IInternalActorRef
    | Edit this page View Source

    Props

    The Props used to create this actor.

    Declaration
    public Props Props { get; }
    Property Value
    Type Description
    Props
    Remarks

    Will be re-used in the event that the actor restarts.

    | Edit this page View Source

    ReceiveTimeout

    TBD

    Declaration
    public TimeSpan? ReceiveTimeout { get; }
    Property Value
    Type Description
    TimeSpan?
    | Edit this page View Source

    Self

    The IActorRef instance that represents the current actor.

    Declaration
    public IActorRef Self { get; }
    Property Value
    Type Description
    IActorRef
    | Edit this page View Source

    Sender

    The actor who sent us CurrentMessage.

    Declaration
    public IActorRef? Sender { get; }
    Property Value
    Type Description
    IActorRef
    Remarks

    Will be null when we are not processing messages.

    | Edit this page View Source

    System

    The ActorSystem this actor belongs to.

    Declaration
    public ActorSystem System { get; }
    Property Value
    Type Description
    ActorSystem
    | Edit this page View Source

    SystemImpl

    INTERNAL API

    Declaration
    public ActorSystemImpl SystemImpl { get; }
    Property Value
    Type Description
    ActorSystemImpl
    | Edit this page View Source

    TaskScheduler

    Used by this actor to schedule Task instances.

    Declaration
    public virtual ActorTaskScheduler TaskScheduler { get; }
    Property Value
    Type Description
    ActorTaskScheduler

    Methods

    | Edit this page View Source

    ActorOf(Props, string?)

    TBD

    Declaration
    public virtual IActorRef ActorOf(Props props, string? name = null)
    Parameters
    Type Name Description
    Props props

    TBD

    string name

    TBD

    Returns
    Type Description
    IActorRef

    A reference to the new child actor.

    Exceptions
    Type Condition
    InvalidActorNameException

    This exception is thrown if the given name is an invalid actor name.

    ArgumentException

    This exception is thrown if a pre-creation serialization occurred.

    InvalidOperationException

    This exception is thrown if the actor tries to create a child while it is terminating or is terminated.

    | Edit this page View Source

    ActorSelection(ActorPath)

    TBD

    Declaration
    public ActorSelection ActorSelection(ActorPath path)
    Parameters
    Type Name Description
    ActorPath path

    TBD

    Returns
    Type Description
    ActorSelection

    TBD

    | Edit this page View Source

    ActorSelection(string)

    TBD

    Declaration
    public ActorSelection ActorSelection(string path)
    Parameters
    Type Name Description
    string path

    TBD

    Returns
    Type Description
    ActorSelection

    TBD

    | Edit this page View Source

    AddWatcher(IActorRef, IActorRef)

    TBD

    Declaration
    protected void AddWatcher(IActorRef watchee, IActorRef watcher)
    Parameters
    Type Name Description
    IActorRef watchee

    TBD

    IActorRef watcher

    TBD

    | Edit this page View Source

    AddressTerminated(Address)

    TBD

    Declaration
    protected void AddressTerminated(Address address)
    Parameters
    Type Name Description
    Address address

    TBD

    | Edit this page View Source

    AttachChild(Props, bool, string?)

    Attaches a child to the current ActorCell.

    This method is used in the process of starting actors.

    Declaration
    public virtual IActorRef AttachChild(Props props, bool isSystemService, string? name = null)
    Parameters
    Type Name Description
    Props props

    The Props this child actor will use.

    bool isSystemService

    If true, then this actor is a system actor and activates a special initialization path.

    string name

    The name of the actor being started. Can be null, and if it is we will automatically generate a random name for this actor.

    Returns
    Type Description
    IActorRef

    A reference to the initialized child actor.

    Exceptions
    Type Condition
    InvalidActorNameException

    This exception is thrown if the given name is an invalid actor name.

    ArgumentException

    This exception is thrown if a pre-creation serialization occurred.

    InvalidOperationException

    This exception is thrown if the actor tries to create a child while it is terminating or is terminated.

    | Edit this page View Source

    AutoReceiveMessage(Envelope)

    TBD

    Declaration
    protected virtual void AutoReceiveMessage(Envelope envelope)
    Parameters
    Type Name Description
    Envelope envelope

    TBD

    Exceptions
    Type Condition
    ActorKilledException

    This exception is thrown if a Kill message is included in the given envelope.

    | Edit this page View Source

    Become(Receive)

    Changes behaviors to the new Receive.

    Declaration
    public void Become(Receive receive)
    Parameters
    Type Name Description
    Receive receive
    Remarks

    Forgets any prior behaviors and doesn't maintain a "behavior stack."

    See BecomeStacked(Receive) if that's what you want.

    | Edit this page View Source

    BecomeStacked(Receive)

    Changes behaviors to the new Receive while maintaining the previous behavior in this actor's "behavior stack."

    Declaration
    public void BecomeStacked(Receive receive)
    Parameters
    Type Name Description
    Receive receive
    Remarks

    Most users typically use Become(Receive) so they can avoid having to maintain a behavior stack.

    Only use this method if you know what you're doing.

    | Edit this page View Source

    CheckReceiveTimeout(bool)

    TBD

    Declaration
    public void CheckReceiveTimeout(bool reschedule = true)
    Parameters
    Type Name Description
    bool reschedule
    | Edit this page View Source

    ClearActor(ActorBase?)

    Clears the actor's state and prepares it for GC.

    Declaration
    protected void ClearActor(ActorBase? actor)
    Parameters
    Type Name Description
    ActorBase actor

    The actor instance.

    Remarks

    Used during actor restarts and shutdowns.

    | Edit this page View Source

    ClearActorCell()

    Clears all the contents of the ActorCell.

    Declaration
    protected void ClearActorCell()
    Remarks

    Used during shutdown.

    | Edit this page View Source

    CreateActorRestartedEvent(Exception)

    Overrideable in order to support issues such as https://github.com/petabridge/phobos-issues/issues/82

    Declaration
    protected virtual ActorRestarted? CreateActorRestartedEvent(Exception cause)
    Parameters
    Type Name Description
    Exception cause
    Returns
    Type Description
    ActorRestarted
    | Edit this page View Source

    CreateActorStartedEvent()

    Overrideable in order to support issues such as https://github.com/petabridge/phobos-issues/issues/82

    Declaration
    protected virtual ActorStarted? CreateActorStartedEvent()
    Returns
    Type Description
    ActorStarted
    | Edit this page View Source

    CreateActorStoppedEvent()

    Overrideable in order to support issues such as https://github.com/petabridge/phobos-issues/issues/82

    Declaration
    protected virtual ActorStopped? CreateActorStoppedEvent()
    Returns
    Type Description
    ActorStopped
    | Edit this page View Source

    CreateNewActorInstance()

    Used to create a new instance of the actor from its Props

    Declaration
    protected virtual ActorBase CreateNewActorInstance()
    Returns
    Type Description
    ActorBase

    A new instance of this actor.

    | Edit this page View Source

    GetChildByName(string)

    Obsolete. Use TryGetChildStatsByName(string, out IChildStats) instead.

    Declaration
    [Obsolete("Use TryGetChildStatsByName [0.7.1]", true)]
    public IInternalActorRef GetChildByName(string name)
    Parameters
    Type Name Description
    string name

    N/A

    Returns
    Type Description
    IInternalActorRef

    N/A

    | Edit this page View Source

    GetChildren()

    Returns all the children of this actor.

    Declaration
    public IEnumerable<IInternalActorRef> GetChildren()
    Returns
    Type Description
    IEnumerable<IInternalActorRef>
    | Edit this page View Source

    GetCurrentSelfOrNoSender()

    TBD

    Declaration
    public static IActorRef? GetCurrentSelfOrNoSender()
    Returns
    Type Description
    IActorRef

    TBD

    | Edit this page View Source

    GetCurrentSenderOrNoSender()

    Gets the current sender or NoSender

    Declaration
    public static IActorRef? GetCurrentSenderOrNoSender()
    Returns
    Type Description
    IActorRef
    | Edit this page View Source

    GetSingleChild(string)

    Get a single child matching the name supplied

    Declaration
    public IInternalActorRef GetSingleChild(string name)
    Parameters
    Type Name Description
    string name

    the child's name

    Returns
    Type Description
    IInternalActorRef

    IInternalActorRef

    | Edit this page View Source

    Init(bool, MailboxType)

    Initialize this cell, i.e. set up mailboxes and supervision. The UID must be reasonably different from the previous UID of a possible actor with the same path, which can be achieved by using ThreadLocalRandom

    Declaration
    public void Init(bool sendSupervise, MailboxType mailboxType)
    Parameters
    Type Name Description
    bool sendSupervise

    TBD

    MailboxType mailboxType

    TBD

    | Edit this page View Source

    InitChild(IInternalActorRef)

    This should only be used privately or when creating the root actor.

    Declaration
    public ChildRestartStats? InitChild(IInternalActorRef actor)
    Parameters
    Type Name Description
    IInternalActorRef actor
    Returns
    Type Description
    ChildRestartStats
    | Edit this page View Source

    Invoke(Envelope)

    Invokes the specified envelope.

    Declaration
    public void Invoke(Envelope envelope)
    Parameters
    Type Name Description
    Envelope envelope

    The envelope.

    Exceptions
    Type Condition
    ActorKilledException

    This exception is thrown if a Kill message is included in the given envelope.

    | Edit this page View Source

    PreStart()

    Allow extra pre-start initialization in derived classes

    Declaration
    protected virtual void PreStart()
    | Edit this page View Source

    PrepareForNewActor()

    Clears the state for a new actor instance following a restart.

    Declaration
    protected void PrepareForNewActor()
    | Edit this page View Source

    ReceiveMessage(object)

    Receives the next message from the mailbox and feeds it to the underlying actor instance.

    Declaration
    protected virtual void ReceiveMessage(object message)
    Parameters
    Type Name Description
    object message

    The message that will be sent to the actor.

    | Edit this page View Source

    ReceiveMessageForTest(Envelope)

    This is only intended to be called from TestKit's TestActorRef

    Declaration
    public void ReceiveMessageForTest(Envelope envelope)
    Parameters
    Type Name Description
    Envelope envelope

    TBD

    | Edit this page View Source

    ReceivedTerminated(Terminated)

    TBD

    Declaration
    protected void ReceivedTerminated(Terminated t)
    Parameters
    Type Name Description
    Terminated t

    TBD

    | Edit this page View Source

    RemWatcher(IActorRef, IActorRef)

    TBD

    Declaration
    protected void RemWatcher(IActorRef watchee, IActorRef watcher)
    Parameters
    Type Name Description
    IActorRef watchee

    TBD

    IActorRef watcher

    TBD

    | Edit this page View Source

    RemoveChildAndGetStateChange(IActorRef)

    Declaration
    protected SuspendReason? RemoveChildAndGetStateChange(IActorRef child)
    Parameters
    Type Name Description
    IActorRef child
    Returns
    Type Description
    SuspendReason
    | Edit this page View Source

    ReserveChild(string)

    Reserve a child actor's name prior to allocating it.

    Declaration
    public void ReserveChild(string name)
    Parameters
    Type Name Description
    string name

    The requested name of the child.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the given name belongs to an actor that is terminating.

    InvalidActorNameException

    This exception is thrown if the given name is not unique in the container.

    | Edit this page View Source

    Restart(Exception)

    Restarts the specified cause.

    Declaration
    public void Restart(Exception cause)
    Parameters
    Type Name Description
    Exception cause

    The cause.

    Remarks

    ➡➡➡ NEVER SEND THE SAME SYSTEM MESSAGE OBJECT TO TWO ACTORS ⬅⬅⬅

    | Edit this page View Source

    Resume(Exception)

    Resumes the specified caused by failure.

    Declaration
    public void Resume(Exception causedByFailure)
    Parameters
    Type Name Description
    Exception causedByFailure

    The caused by failure.

    Remarks

    ➡➡➡ NEVER SEND THE SAME SYSTEM MESSAGE OBJECT TO TWO ACTORS ⬅⬅⬅

    | Edit this page View Source

    SendMessage(Envelope)

    Used to send a message to the actor's mailbox.

    Declaration
    public virtual void SendMessage(Envelope message)
    Parameters
    Type Name Description
    Envelope message

    The message + sender envelope.

    | Edit this page View Source

    SendMessage(IActorRef, object)

    Used to send a message to the actor's mailbox.

    Declaration
    public virtual void SendMessage(IActorRef sender, object message)
    Parameters
    Type Name Description
    IActorRef sender

    The sender of the message.

    object message

    The message to send.

    | Edit this page View Source

    SendSystemMessage(ISystemMessage)

    Handles a ISystemMessage

    Declaration
    public virtual void SendSystemMessage(ISystemMessage systemMessage)
    Parameters
    Type Name Description
    ISystemMessage systemMessage

    The system message to process.

    Remarks

    ➡➡➡ NEVER SEND THE SAME SYSTEM MESSAGE OBJECT TO TWO ACTORS ⬅⬅⬅

    | Edit this page View Source

    SetActorFields(ActorBase?)

    Declaration
    protected static void SetActorFields(ActorBase? actor)
    Parameters
    Type Name Description
    ActorBase actor
    | Edit this page View Source

    SetChildrenTerminationReason(SuspendReason)

    Declaration
    protected bool SetChildrenTerminationReason(SuspendReason reason)
    Parameters
    Type Name Description
    SuspendReason reason
    Returns
    Type Description
    bool
    | Edit this page View Source

    SetReceiveTimeout(TimeSpan?)

    Sets the receive timeout for this actor - which will trigger a ReceiveTimeout message to be delivered into the actor's mailbox when time is up.

    Declaration
    public void SetReceiveTimeout(TimeSpan? timeout = null)
    Parameters
    Type Name Description
    TimeSpan? timeout

    The timeframe. If null is passed here it will cancel any pending receive timeouts. If set to a value greater than Zero then that will become the new receive timeout value.

    | Edit this page View Source

    SetTerminated()

    Declaration
    protected void SetTerminated()
    | Edit this page View Source

    Start()

    Starts this instance.

    Declaration
    public virtual void Start()
    | Edit this page View Source

    Stash(SystemMessage)

    TBD

    Declaration
    protected void Stash(SystemMessage msg)
    Parameters
    Type Name Description
    SystemMessage msg

    TBD

    | Edit this page View Source

    Stop()

    Async stop this actor

    Declaration
    public void Stop()
    Remarks

    ➡➡➡ NEVER SEND THE SAME SYSTEM MESSAGE OBJECT TO TWO ACTORS ⬅⬅⬅

    | Edit this page View Source

    Stop(IActorRef)

    Stops the specified child.

    Declaration
    public void Stop(IActorRef child)
    Parameters
    Type Name Description
    IActorRef child

    The child.

    | Edit this page View Source

    StopFunctionRefs()

    Declaration
    protected void StopFunctionRefs()
    | Edit this page View Source

    Suspend()

    Suspends this instance.

    Declaration
    public void Suspend()
    Remarks

    ➡➡➡ NEVER SEND THE SAME SYSTEM MESSAGE OBJECT TO TWO ACTORS ⬅⬅⬅

    | Edit this page View Source

    TellWatchersWeDied()

    TBD

    Declaration
    protected void TellWatchersWeDied()
    | Edit this page View Source

    TerminatedQueuedFor(IActorRef, Option<object>)

    TBD

    Declaration
    public void TerminatedQueuedFor(IActorRef subject, Option<object> customMessage)
    Parameters
    Type Name Description
    IActorRef subject

    Tracked subject

    Option<object> customMessage

    Terminated custom message

    | Edit this page View Source

    TryGetChildStatsByName(string, out IChildStats)

    Tries to get the stats for the child with the specified name. The stats can be either ChildNameReserved indicating that only a name has been reserved for the child, or a ChildRestartStats for a child that has been initialized/created.

    Declaration
    public bool TryGetChildStatsByName(string name, out IChildStats child)
    Parameters
    Type Name Description
    string name
    IChildStats child
    Returns
    Type Description
    bool
    | Edit this page View Source

    TryGetChildStatsByRef(IActorRef, out ChildRestartStats?)

    Tries to get the stats for the specified child. Since the child exists ChildRestartStats is the only valid IChildStats.

    Declaration
    protected bool TryGetChildStatsByRef(IActorRef actor, out ChildRestartStats? child)
    Parameters
    Type Name Description
    IActorRef actor
    ChildRestartStats child
    Returns
    Type Description
    bool
    | Edit this page View Source

    UnbecomeStacked()

    Used in combination with BecomeStacked(Receive) - used to pop old behaviors off of the stack.

    Declaration
    public void UnbecomeStacked()
    | Edit this page View Source

    UnreserveChild(string)

    Unreserve a child actor's name.

    Declaration
    protected void UnreserveChild(string name)
    Parameters
    Type Name Description
    string name

    The child's name.

    | Edit this page View Source

    Unwatch(IActorRef)

    TBD

    Declaration
    public IActorRef Unwatch(IActorRef subject)
    Parameters
    Type Name Description
    IActorRef subject

    TBD

    Returns
    Type Description
    IActorRef

    TBD

    | Edit this page View Source

    UnwatchWatchedActors(ActorBase?)

    INTERNAL API

    Declaration
    protected void UnwatchWatchedActors(ActorBase? actor)
    Parameters
    Type Name Description
    ActorBase actor
    Remarks

    Cleanup routine during actor shutdown.

    | Edit this page View Source

    UseThreadContext(Action)

    Performs an activity inside this actor's thread-safe context.

    Declaration
    public void UseThreadContext(Action action)
    Parameters
    Type Name Description
    Action action

    The action to perform.

    | Edit this page View Source

    Watch(IActorRef)

    TBD

    Declaration
    public IActorRef Watch(IActorRef subject)
    Parameters
    Type Name Description
    IActorRef subject

    TBD

    Returns
    Type Description
    IActorRef

    TBD

    | Edit this page View Source

    WatchWith(IActorRef, object)

    TBD

    Declaration
    public IActorRef WatchWith(IActorRef subject, object message)
    Parameters
    Type Name Description
    IActorRef subject

    TBD

    object message

    TBD

    Returns
    Type Description
    IActorRef

    TBD

    | Edit this page View Source

    WatchedActorTerminated(IActorRef, bool, bool)

    When this actor is watching the subject of Terminated message it will be propagated to user's receive.

    Declaration
    protected void WatchedActorTerminated(IActorRef actor, bool existenceConfirmed, bool addressTerminated)
    Parameters
    Type Name Description
    IActorRef actor

    TBD

    bool existenceConfirmed

    TBD

    bool addressTerminated

    TBD

    Implements

    IUntypedActorContext
    IActorContext
    IActorRefFactory
    ICanWatch

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    StashFactory.CreateStash(IActorContext, IActorStash)
    StashFactory.CreateStash(IActorContext, Type)
    StashFactory.CreateStash<T>(IActorContext)
    Logging.GetLogger(IActorContext, ILogMessageFormatter)
    ActorRefFactoryExtensions.ActorOf<TActor>(IActorRefFactory, string)
    ActorRefFactoryExtensions.ActorSelection(IActorRefFactory, IActorRef, string)
    ActExtensions.ActorOf(IActorRefFactory, Action<IActorDsl, IActorContext>, string)
    ActExtensions.ActorOf(IActorRefFactory, Action<IActorDsl>, string)
    ActorMaterializerExtensions.Materializer(IActorRefFactory, ActorMaterializerSettings, string)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET