Class ActorCell
INTERNAL API.
The hosting infrastructure for actors.
Inherited Members
Namespace: Akka.Actor
Assembly: Akka.dll
Syntax
public class ActorCell : IUntypedActorContext, IActorContext, IActorRefFactory, ICanWatch
Constructors
| Edit this page View SourceActorCell(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 SourceUndefinedUid
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 SourceChildrenContainer
The child container collection, used to house information about all child actors.
Declaration
public IChildrenContainer ChildrenContainer { get; }
Property Value
| Type | Description |
|---|---|
| IChildrenContainer |
CurrentEnvelopeId
INTERNAL API
Declaration
public int CurrentEnvelopeId { get; }
Property Value
| Type | Description |
|---|---|
| int |
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.
Dispatcher
This actor's message dispatcher.
Declaration
public MessageDispatcher Dispatcher { get; }
Property Value
| Type | Description |
|---|---|
| MessageDispatcher |
HasMessages
Will return true if NumberOfMessages is greater than zero.
Declaration
public bool HasMessages { get; }
Property Value
| Type | Description |
|---|---|
| bool |
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 |
IsNormal
Declaration
protected bool IsNormal { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsTerminated
Indicates whether the actor is currently terminated.
Declaration
public bool IsTerminated { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsTerminating
Declaration
protected bool IsTerminating { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Mailbox
This actor's mailbox instance.
Declaration
public Mailbox? Mailbox { get; }
Property Value
| Type | Description |
|---|---|
| Mailbox |
NumberOfMessages
Current message count inside the mailbox.
Declaration
public int NumberOfMessages { get; }
Property Value
| Type | Description |
|---|---|
| int |
Parent
This actor's parent actor.
Declaration
public IInternalActorRef Parent { get; }
Property Value
| Type | Description |
|---|---|
| IInternalActorRef |
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.
ReceiveTimeout
TBD
Declaration
public TimeSpan? ReceiveTimeout { get; }
Property Value
| Type | Description |
|---|---|
| TimeSpan? |
Self
The IActorRef instance that represents the current actor.
Declaration
public IActorRef Self { get; }
Property Value
| Type | Description |
|---|---|
| IActorRef |
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.
System
The ActorSystem this actor belongs to.
Declaration
public ActorSystem System { get; }
Property Value
| Type | Description |
|---|---|
| ActorSystem |
SystemImpl
INTERNAL API
Declaration
public ActorSystemImpl SystemImpl { get; }
Property Value
| Type | Description |
|---|---|
| ActorSystemImpl |
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 SourceActorOf(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 |
| 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. |
ActorSelection(ActorPath)
TBD
Declaration
public ActorSelection ActorSelection(ActorPath path)
Parameters
| Type | Name | Description |
|---|---|---|
| ActorPath | path | TBD |
Returns
| Type | Description |
|---|---|
| ActorSelection | TBD |
ActorSelection(string)
TBD
Declaration
public ActorSelection ActorSelection(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | TBD |
Returns
| Type | Description |
|---|---|
| ActorSelection | TBD |
AddWatcher(IActorRef, IActorRef)
TBD
Declaration
protected void AddWatcher(IActorRef watchee, IActorRef watcher)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | watchee | TBD |
| IActorRef | watcher | TBD |
AddressTerminated(Address)
TBD
Declaration
protected void AddressTerminated(Address address)
Parameters
| Type | Name | Description |
|---|---|---|
| Address | address | TBD |
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 |
| string | name | The name of the actor being started. Can be |
Returns
| Type | Description |
|---|---|
| IActorRef | A reference to the initialized child actor. |
Exceptions
| Type | Condition |
|---|---|
| InvalidActorNameException | This exception is thrown if the given |
| 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. |
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 |
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.
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.
CheckReceiveTimeout(bool)
TBD
Declaration
public void CheckReceiveTimeout(bool reschedule = true)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | reschedule |
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.
ClearActorCell()
Clears all the contents of the ActorCell.
Declaration
protected void ClearActorCell()
Remarks
Used during shutdown.
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 |
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 |
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 |
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. |
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 |
GetChildren()
Returns all the children of this actor.
Declaration
public IEnumerable<IInternalActorRef> GetChildren()
Returns
| Type | Description |
|---|---|
| IEnumerable<IInternalActorRef> |
GetCurrentSelfOrNoSender()
TBD
Declaration
public static IActorRef? GetCurrentSelfOrNoSender()
Returns
| Type | Description |
|---|---|
| IActorRef | TBD |
GetCurrentSenderOrNoSender()
Gets the current sender or NoSender
Declaration
public static IActorRef? GetCurrentSenderOrNoSender()
Returns
| Type | Description |
|---|---|
| IActorRef |
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 |
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 |
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 |
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 |
PreStart()
Allow extra pre-start initialization in derived classes
Declaration
protected virtual void PreStart()
PrepareForNewActor()
Clears the state for a new actor instance following a restart.
Declaration
protected void PrepareForNewActor()
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. |
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 |
ReceivedTerminated(Terminated)
TBD
Declaration
protected void ReceivedTerminated(Terminated t)
Parameters
| Type | Name | Description |
|---|---|---|
| Terminated | t | TBD |
RemWatcher(IActorRef, IActorRef)
TBD
Declaration
protected void RemWatcher(IActorRef watchee, IActorRef watcher)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | watchee | TBD |
| IActorRef | watcher | TBD |
RemoveChildAndGetStateChange(IActorRef)
Declaration
protected SuspendReason? RemoveChildAndGetStateChange(IActorRef child)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | child |
Returns
| Type | Description |
|---|---|
| SuspendReason |
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 |
| InvalidActorNameException | This exception is thrown if the given |
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 ⬅⬅⬅
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 ⬅⬅⬅
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. |
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. |
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 ⬅⬅⬅
SetActorFields(ActorBase?)
Declaration
protected static void SetActorFields(ActorBase? actor)
Parameters
| Type | Name | Description |
|---|---|---|
| ActorBase | actor |
SetChildrenTerminationReason(SuspendReason)
Declaration
protected bool SetChildrenTerminationReason(SuspendReason reason)
Parameters
| Type | Name | Description |
|---|---|---|
| SuspendReason | reason |
Returns
| Type | Description |
|---|---|
| bool |
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 |
SetTerminated()
Declaration
protected void SetTerminated()
Start()
Starts this instance.
Declaration
public virtual void Start()
Stash(SystemMessage)
TBD
Declaration
protected void Stash(SystemMessage msg)
Parameters
| Type | Name | Description |
|---|---|---|
| SystemMessage | msg | TBD |
Stop()
Async stop this actor
Declaration
public void Stop()
Remarks
➡➡➡ NEVER SEND THE SAME SYSTEM MESSAGE OBJECT TO TWO ACTORS ⬅⬅⬅
Stop(IActorRef)
Stops the specified child.
Declaration
public void Stop(IActorRef child)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | child | The child. |
StopFunctionRefs()
Declaration
protected void StopFunctionRefs()
Suspend()
Suspends this instance.
Declaration
public void Suspend()
Remarks
➡➡➡ NEVER SEND THE SAME SYSTEM MESSAGE OBJECT TO TWO ACTORS ⬅⬅⬅
TellWatchersWeDied()
TBD
Declaration
protected void TellWatchersWeDied()
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 |
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 |
TryGetChildStatsByRef(IActorRef, out ChildRestartStats?)
Tries to get the stats for the specified child.
Declaration
protected bool TryGetChildStatsByRef(IActorRef actor, out ChildRestartStats? child)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | actor | |
| ChildRestartStats | child |
Returns
| Type | Description |
|---|---|
| bool |
UnbecomeStacked()
Used in combination with BecomeStacked(Receive) - used to pop old behaviors off of the stack.
Declaration
public void UnbecomeStacked()
UnreserveChild(string)
Unreserve a child actor's name.
Declaration
protected void UnreserveChild(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The child's name. |
Unwatch(IActorRef)
TBD
Declaration
public IActorRef Unwatch(IActorRef subject)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | subject | TBD |
Returns
| Type | Description |
|---|---|
| IActorRef | TBD |
UnwatchWatchedActors(ActorBase?)
INTERNAL API
Declaration
protected void UnwatchWatchedActors(ActorBase? actor)
Parameters
| Type | Name | Description |
|---|---|---|
| ActorBase | actor |
Remarks
Cleanup routine during actor shutdown.
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. |
Watch(IActorRef)
TBD
Declaration
public IActorRef Watch(IActorRef subject)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | subject | TBD |
Returns
| Type | Description |
|---|---|
| IActorRef | TBD |
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 |
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 |
Edit this page