-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1484 from JeffCyr/ActorTaskScheduler-refactoring
ActorTaskScheduler refactoring with benchmark
- Loading branch information
Showing
9 changed files
with
364 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="ClientReceiveActor.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com> | ||
// Copyright (C) 2013-2015 Akka.NET project <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
//----------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using Akka.Actor; | ||
|
||
#pragma warning disable 1998 //async method lacks an await | ||
|
||
namespace PingPong | ||
{ | ||
public class ClientAsyncActor : ReceiveActor | ||
{ | ||
public ClientAsyncActor(IActorRef actor, long repeat, TaskCompletionSource<bool> latch) | ||
{ | ||
var received = 0L; | ||
var sent = 0L; | ||
Receive<Messages.Msg>(async m => | ||
{ | ||
received++; | ||
if (sent < repeat) | ||
{ | ||
actor.Tell(m); | ||
sent++; | ||
} | ||
else if (received >= repeat) | ||
{ | ||
latch.SetResult(true); | ||
} | ||
}); | ||
Receive<Messages.Run>(r => | ||
{ | ||
var msg = new Messages.Msg(); | ||
for (int i = 0; i < Math.Min(1000, repeat); i++) | ||
{ | ||
actor.Tell(msg); | ||
sent++; | ||
} | ||
}); | ||
Receive<Messages.Started>(s => Sender.Tell(s)); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.