Skip to content

Commit 15492d0

Browse files
Reduced allocations around ActorCell and Task handling (#5053)
* Made `ActorCell.SendSystemMessage` `virtual` so it can be subclassed * Made a number of `ActorCell` methods `static` to reduce object memory footprint * Reduced number of possible `Task` allocations where they weren't needed
1 parent 2715c36 commit 15492d0

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ namespace Akka.Actor
110110
public void Resume(System.Exception causedByFailure) { }
111111
public virtual void SendMessage(Akka.Actor.Envelope message) { }
112112
public virtual void SendMessage(Akka.Actor.IActorRef sender, object message) { }
113-
public void SendSystemMessage(Akka.Dispatch.SysMsg.ISystemMessage systemMessage) { }
113+
public virtual void SendSystemMessage(Akka.Dispatch.SysMsg.ISystemMessage systemMessage) { }
114114
protected void SetActorFields(Akka.Actor.ActorBase actor) { }
115115
protected bool SetChildrenTerminationReason(Akka.Actor.Internal.SuspendReason reason) { }
116116
public void SetReceiveTimeout(System.Nullable<System.TimeSpan> timeout = null) { }

src/core/Akka/Actor/ActorCell.DefaultMessages.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ private void Supervise(IActorRef child, bool async)
401401
}
402402
}
403403

404-
private void HandleSupervise(IActorRef child, bool async)
404+
private static void HandleSupervise(IActorRef child, bool async)
405405
{
406406
if (async && child is RepointableActorRef @ref)
407407
{
@@ -506,11 +506,11 @@ public void Suspend()
506506
}
507507

508508
/// <summary>
509-
/// TBD
509+
/// Handles a <see cref="ISystemMessage"/>
510510
/// </summary>
511511
/// <remarks>➡➡➡ NEVER SEND THE SAME SYSTEM MESSAGE OBJECT TO TWO ACTORS ⬅⬅⬅</remarks>
512-
/// <param name="systemMessage">TBD</param>
513-
public void SendSystemMessage(ISystemMessage systemMessage)
512+
/// <param name="systemMessage">The system message to process.</param>
513+
public virtual void SendSystemMessage(ISystemMessage systemMessage)
514514
{
515515
try
516516
{
@@ -522,7 +522,7 @@ public void SendSystemMessage(ISystemMessage systemMessage)
522522
}
523523
}
524524

525-
private void Kill()
525+
private static void Kill()
526526
{
527527
throw new ActorKilledException("Kill");
528528
}

src/core/Akka/Actor/ReceiveActor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private PartialAction<object> CreateNewHandler(Action configure)
111111
return newHandler;
112112
}
113113

114-
private Action<T> WrapAsyncHandler<T>(Func<T, Task> asyncHandler)
114+
private static Action<T> WrapAsyncHandler<T>(Func<T, Task> asyncHandler)
115115
{
116116
return m =>
117117
{

src/core/Akka/Dispatch/ActorTaskScheduler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static void RunTask(Action action)
116116
RunTask(() =>
117117
{
118118
action();
119-
return Task.FromResult(0);
119+
return Task.CompletedTask;
120120
});
121121
}
122122

0 commit comments

Comments
 (0)