Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

Access to modified closure #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Stact.Benchmarks/PingPongBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ public void Run()

for (int i = actorCount; i >= 0; i--)
{
actors[i] = AnonymousActor.New(inbox =>
var i1 = i; // Fix for access to modified closure.
actors[i1] = AnonymousActor.New(inbox =>
{
var pong = new Pong();

var server = actors[(i + 1)];
var server = actors[0]; //The first actor will be the server

inbox.Loop(loop =>
{
Expand All @@ -51,7 +52,7 @@ public void Run()
});


if (i < actorCount)
if (i1 > 0) //if we aren't the server
{
var ping = new Ping();
int count = 0;
Expand Down