本文整理汇总了C#中Akka.TestKit.TestLatch.CountDown方法的典型用法代码示例。如果您正苦于以下问题:C# TestLatch.CountDown方法的具体用法?C# TestLatch.CountDown怎么用?C# TestLatch.CountDown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akka.TestKit.TestLatch
的用法示例。
在下文中一共展示了TestLatch.CountDown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Smallest_mailbox_pool_must_deliver_messages_to_idle_actor
public void Smallest_mailbox_pool_must_deliver_messages_to_idle_actor()
{
var usedActors = new ConcurrentDictionary<int, string>();
var router = Sys.ActorOf(new SmallestMailboxPool(3).Props(Props.Create(() => new SmallestMailboxActor(usedActors))));
var busy = new TestLatch(1);
var received0 = new TestLatch(1);
router.Tell(Tuple.Create(busy, received0));
received0.Ready(TestKitSettings.DefaultTimeout);
var received1 = new TestLatch(1);
router.Tell(Tuple.Create(1, received1));
received1.Ready(TestKitSettings.DefaultTimeout);
var received2 = new TestLatch(1);
router.Tell(Tuple.Create(2, received2));
received2.Ready(TestKitSettings.DefaultTimeout);
var received3 = new TestLatch(1);
router.Tell(Tuple.Create(3, received3));
received3.Ready(TestKitSettings.DefaultTimeout);
busy.CountDown();
var busyPath = usedActors[0];
busyPath.Should().NotBeNull();
var path1 = usedActors[1];
var path2 = usedActors[2];
var path3 = usedActors[3];
path1.Should().NotBeNull(busyPath);
path2.Should().NotBeNull(busyPath);
path3.Should().NotBeNull(busyPath);
}
示例2: RoundRobinPoolBroadcastActor
public RoundRobinPoolBroadcastActor(TestLatch helloLatch, TestLatch stopLatch)
{
_helloLatch = helloLatch;
_stopLatch = stopLatch;
Receive<string>(s => s == "hello", c => _helloLatch.CountDown());
}
示例3: Watcher
public Watcher(TestLatch exitingLatch, TestLatch removedLatch, Address secondAddress)
{
_exitingLatch = exitingLatch;
_removedLatch = removedLatch;
_secondAddress = secondAddress;
Receive<ClusterEvent.CurrentClusterState>(state =>
{
if (state.Members.Any(m => m.Address == _secondAddress && m.Status == MemberStatus.Exiting))
_exitingLatch.CountDown();
});
Receive<ClusterEvent.MemberExited>(m =>
{
if (m.Member.Address == secondAddress)
{
exitingLatch.CountDown();
}
});
Receive<ClusterEvent.MemberRemoved>(m =>
{
if (m.Member.Address == secondAddress)
{
_removedLatch.CountDown();
}
});
}
示例4: BroadcastTarget
public BroadcastTarget(TestLatch doneLatch, AtomicCounter counter)
{
_doneLatch = doneLatch;
_counter = counter;
Receive<string>(s => s == "end", c => _doneLatch.CountDown());
Receive<int>(msg => _counter.AddAndGet(msg));
}
示例5: RoundRobinPoolActor
public RoundRobinPoolActor(TestLatch doneLatch, AtomicCounter counter)
{
_doneLatch = doneLatch;
_counter = counter;
Receive<string>(s => s == "hit", c => Sender.Tell(id.Value));
Receive<string>(s => s == "end", c => _doneLatch.CountDown());
}
示例6: Listener
public Listener(TestLatch latch, ImmutableList<Address> expectedAddresses)
{
_latch = latch;
_expectedAddresses = expectedAddresses;
Receive<ClusterEvent.CurrentClusterState>(state =>
{
_members = state.Members;
});
Receive<ClusterEvent.MemberUp>(m =>
{
_members = _members.Remove(m.Member).Add(m.Member);
if (!_members.Select(c => c.Address).Except(_expectedAddresses).Any())
_latch.CountDown();
});
}
示例7: Smallest_mailbox_router_must_deliver_messages_to_idle_actor
public void Smallest_mailbox_router_must_deliver_messages_to_idle_actor()
{
var usedActors = new ConcurrentDictionary<int, string>();
var router = Sys.ActorOf(new SmallestMailboxPool(3).Props(Props.Create(() => new SmallestMailboxActor(usedActors))));
var busy = new TestLatch(1);
var received0 = new TestLatch(1);
router.Tell(Tuple.Create(busy, received0));
received0.Ready(TestLatch.DefaultTimeout);
var received1 = new TestLatch(1);
router.Tell(Tuple.Create(1, received1));
received1.Ready(TestLatch.DefaultTimeout);
var received2 = new TestLatch(1);
router.Tell(Tuple.Create(2, received2));
received2.Ready(TestLatch.DefaultTimeout);
var received3 = new TestLatch(1);
router.Tell(Tuple.Create(3, received3));
received3.Ready(TestLatch.DefaultTimeout);
busy.CountDown();
var busyPath = usedActors[0];
Assert.NotEqual(busyPath, null);
Assert.Equal(usedActors.Count, 4);
var path1 = usedActors[1];
var path2 = usedActors[2];
var path3 = usedActors[3];
Assert.NotEqual(path1, busyPath);
Assert.NotEqual(path2, busyPath);
Assert.NotEqual(path3, busyPath);
}
示例8: A_Flow_with_SelectAsyncUnordered_must_signal_error_from_SelectAsyncUnordered
public void A_Flow_with_SelectAsyncUnordered_must_signal_error_from_SelectAsyncUnordered()
{
this.AssertAllStagesStopped(() =>
{
var latch = new TestLatch(1);
var c = this.CreateManualSubscriberProbe<int>();
Source.From(Enumerable.Range(1, 5))
.SelectAsyncUnordered(4, n =>
{
if (n == 3)
throw new TestException("err2");
return Task.Run(() =>
{
latch.Ready(TimeSpan.FromSeconds(10));
return n;
});
})
.RunWith(Sink.FromSubscriber(c), Materializer);
var sub = c.ExpectSubscription();
sub.Request(10);
c.ExpectError().Message.Should().Be("err2");
latch.CountDown();
}, Materializer);
}
示例9: RoundRobinGroupActor
public RoundRobinGroupActor(TestLatch doneLatch)
{
_doneLatch = doneLatch;
Receive<string>(s => s == "hit", c => Sender.Tell(Self.Path.Name));
Receive<string>(s => s == "end", c => _doneLatch.CountDown());
}
示例10: InputStreamSource_must_emit_as_soon_as_read
public void InputStreamSource_must_emit_as_soon_as_read()
{
this.AssertAllStagesStopped(() =>
{
var latch = new TestLatch(1);
var probe = StreamConverters.FromInputStream(() => new EmittedInputStream(latch), chunkSize: 1)
.RunWith(this.SinkProbe<ByteString>(), _materializer);
probe.Request(4);
probe.ExpectNext(ByteString.FromString("M"));
latch.CountDown();
probe.ExpectComplete();
}, _materializer);
}
示例11: A_Flow_with_SelectAsync_must_signal_task_failure
public void A_Flow_with_SelectAsync_must_signal_task_failure()
{
this.AssertAllStagesStopped(() =>
{
var latch = new TestLatch(1);
var c = TestSubscriber.CreateManualProbe<int>(this);
Source.From(Enumerable.Range(1, 5))
.SelectAsync(4, n => Task.Run(() =>
{
if (n == 3)
throw new TestException("err1");
latch.Ready(TimeSpan.FromSeconds(10));
return n;
}))
.To(Sink.FromSubscriber(c)).Run(Materializer);
var sub = c.ExpectSubscription();
sub.Request(10);
c.ExpectError().InnerException.Message.Should().Be("err1");
latch.CountDown();
}, Materializer);
}
示例12: A_FlattenMerge_must_cancel_substreams_when_failing_map_function
public void A_FlattenMerge_must_cancel_substreams_when_failing_map_function()
{
var settings = ActorMaterializerSettings.Create(Sys).WithSyncProcessingLimit(1);
var materializer = ActorMaterializer.Create(Sys, settings);
var p = TestPublisher.CreateProbe<int>(this);
var ex = new TestException("buh");
var latch = new TestLatch();
Source.From(Enumerable.Range(1, 3)).MergeMany(10, i =>
{
if (i == 1)
return Source.FromPublisher(p);
latch.Ready(TimeSpan.FromSeconds(3));
throw ex;
}).RunWith(Sink.First<int>(), materializer);
p.ExpectRequest();
latch.CountDown();
p.ExpectCancellation();
}
示例13: A_ForeachParallel_must_resume_after_function_failure
public void A_ForeachParallel_must_resume_after_function_failure()
{
this.AssertAllStagesStopped(() =>
{
var probe = CreateTestProbe();
var latch = new TestLatch(1);
var p = Source.From(Enumerable.Range(1, 5)).RunWith(Sink.ForEachParallel<int>(4, n =>
{
if (n == 3)
throw new TestException("err1");
probe.Ref.Tell(n);
latch.Ready(TimeSpan.FromSeconds(10));
}).WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.ResumingDecider)), Materializer);
latch.CountDown();
probe.ExpectMsgAllOf(1, 2, 4, 5);
p.Wait(TimeSpan.FromSeconds(5)).Should().BeTrue();
}, Materializer);
}
示例14: A_ForeachParallel_must_finish_after_function_thrown_exception
public void A_ForeachParallel_must_finish_after_function_thrown_exception()
{
this.AssertAllStagesStopped(() =>
{
var probe = CreateTestProbe();
var latch = new TestLatch(1);
var p = Source.From(Enumerable.Range(1, 5)).RunWith(Sink.ForEachParallel<int>(3, n =>
{
if (n == 3)
throw new TestException("err2");
probe.Ref.Tell(n);
latch.Ready(TimeSpan.FromSeconds(10));
}).WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.StoppingDecider)), Materializer);
// make sure the stream is up and running, otherwise the latch is maybe ready before the third message arrives
Thread.Sleep(500);
latch.CountDown();
probe.ExpectMsgAllOf(1, 2);
var ex = p.Invoking(t => t.Wait(TimeSpan.FromSeconds(1))).ShouldThrow<AggregateException>().Which;
ex.Flatten().InnerException.Should().BeOfType<TestException>();
ex.Flatten().InnerException.Message.Should().Be("err2");
p.IsCompleted.Should().BeTrue();
}, Materializer);
}
示例15: Observer
public Observer(ActorPath path2, ActorPath path3, TestLatch watchEstablished, IActorRef testActorRef)
{
_watchEstablished = watchEstablished;
_testActorRef = testActorRef;
Receive<ActorIdentity>(identity => identity.MessageId.Equals(path2), identity =>
{
Context.Watch(identity.Subject);
_watchEstablished.CountDown();
});
Receive<ActorIdentity>(identity => identity.MessageId.Equals(path3), identity =>
{
Context.Watch(identity.Subject);
_watchEstablished.CountDown();
});
Receive<Terminated>(terminated =>
{
_testActorRef.Tell(terminated.ActorRef.Path);
});
Context.ActorSelection(path2).Tell(new Identify(path2));
Context.ActorSelection(path3).Tell(new Identify(path3));
}