本文整理汇总了C#中Akka.TestKit.TestLatch类的典型用法代码示例。如果您正苦于以下问题:C# TestLatch类的具体用法?C# TestLatch怎么用?C# TestLatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestLatch类属于Akka.TestKit命名空间,在下文中一共展示了TestLatch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ListenerActor
public ListenerActor(TestLatch fooLatch, TestLatch barLatch, AtomicCounter barCount)
{
_fooLatch = fooLatch;
_barLatch = barLatch;
_barCount = barCount;
Listeners = new ListenerSupport();
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:7,代码来源:ListenerSpec.cs
示例2: 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();
}
});
}
开发者ID:Micha-kun,项目名称:akka.net,代码行数:26,代码来源:MembershipChangeListenerExitingSpec.cs
示例3: RoundRobinPoolBroadcastActor
public RoundRobinPoolBroadcastActor(TestLatch helloLatch, TestLatch stopLatch)
{
_helloLatch = helloLatch;
_stopLatch = stopLatch;
Receive<string>(s => s == "hello", c => _helloLatch.CountDown());
}
开发者ID:Micha-kun,项目名称:akka.net,代码行数:7,代码来源:RoundRobinSpec.cs
示例4: 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);
}
开发者ID:Micha-kun,项目名称:akka.net,代码行数:35,代码来源:SmallestMailboxSpec.cs
示例5: Listener_must_listen_in
public void Listener_must_listen_in()
{
//arrange
var fooLatch = new TestLatch(2);
var barLatch = new TestLatch(2);
var barCount = new AtomicCounter(0);
var broadcast = Sys.ActorOf<BroadcastActor>();
var newListenerProps = Props.Create(() => new ListenerActor(fooLatch, barLatch, barCount));
var a1 = Sys.ActorOf(newListenerProps);
var a2 = Sys.ActorOf(newListenerProps);
var a3 = Sys.ActorOf(newListenerProps);
//act
broadcast.Tell(new Listen(a1));
broadcast.Tell(new Listen(a2));
broadcast.Tell(new Listen(a3));
broadcast.Tell(new Deafen(a3));
broadcast.Tell(new WithListeners(a => a.Tell("foo")));
broadcast.Tell("foo");
//assert
barLatch.Ready(TestLatch.DefaultTimeout);
Assert.Equal(2, barCount.Current);
fooLatch.Ready(TestLatch.DefaultTimeout);
foreach (var actor in new[] {a1, a2, a3, broadcast})
{
Sys.Stop(actor);
}
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:33,代码来源:ListenerSpec.cs
示例6: GetTimeout
public void GetTimeout()
{
var timeoutLatch = new TestLatch();
var timeoutActor = Sys.ActorOf(Props.Create(() => new TimeoutActor(timeoutLatch)));
timeoutLatch.Ready(TestLatch.DefaultTimeout);
Sys.Stop(timeoutActor);
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:8,代码来源:ReceiveTimeoutSpec.cs
示例7: 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());
}
开发者ID:Micha-kun,项目名称:akka.net,代码行数:8,代码来源:RoundRobinSpec.cs
示例8: 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));
}
开发者ID:Micha-kun,项目名称:akka.net,代码行数:8,代码来源:TailChoppingSpec.cs
示例9: Props_must_create_actor_by_producer
public void Props_must_create_actor_by_producer()
{
TestLatch latchProducer = new TestLatch(Sys);
TestLatch latchActor = new TestLatch(Sys);
var props = Props.CreateBy<TestProducer>(latchProducer, latchActor);
ActorRef actor = Sys.ActorOf(props);
latchActor.Ready(TimeSpan.FromSeconds(1));
}
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:8,代码来源:PropsSpec.cs
示例10: RescheduleTimeout
public void RescheduleTimeout()
{
var timeoutLatch = new TestLatch(Sys);
var timeoutActor = Sys.ActorOf(Props.Create(() => new TimeoutActor(timeoutLatch)));
timeoutActor.Tell(Tick);
timeoutLatch.Ready(TestLatch.DefaultTimeout);
Sys.Stop(timeoutActor);
}
开发者ID:ClusterReply,项目名称:akka.net,代码行数:8,代码来源:ReceiveTimeoutSpec.cs
示例11: BroadcastGroup_router_must_broadcast_message_using_Ask
public void BroadcastGroup_router_must_broadcast_message_using_Ask()
{
var doneLatch = new TestLatch(2);
var counter1 = new AtomicCounter(0);
var counter2 = new AtomicCounter(0);
var actor1 = Sys.ActorOf(Props.Create(() => new BroadcastTarget(doneLatch, counter1)));
var actor2 = Sys.ActorOf(Props.Create(() => new BroadcastTarget(doneLatch, counter2)));
var routedActor = Sys.ActorOf(Props.Create<TestActor>().WithRouter(new BroadcastGroup(actor1.Path.ToString(), actor2.Path.ToString())));
routedActor.Ask(new Broadcast(1));
routedActor.Tell(new Broadcast("end"));
doneLatch.Ready(TimeSpan.FromSeconds(1));
counter1.Current.ShouldBe(1);
counter2.Current.ShouldBe(1);
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:17,代码来源:BroadcastSpec.cs
示例12: 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();
});
}
开发者ID:Micha-kun,项目名称:akka.net,代码行数:18,代码来源:MembershipChangeListenerUpSpec.cs
示例13: Scatter_gather_router_must_deliver_a_broadcast_message_using_tell
public void Scatter_gather_router_must_deliver_a_broadcast_message_using_tell()
{
var doneLatch = new TestLatch(sys, 2);
var counter1 = new AtomicInteger(0);
var counter2 = new AtomicInteger(0);
var actor1 = sys.ActorOf(Props.Create(() => new BroadcastTarget(doneLatch, counter1)));
var actor2 = sys.ActorOf(Props.Create(() => new BroadcastTarget(doneLatch, counter2)));
var routedActor = sys.ActorOf(Props.Create<TestActor>().WithRouter(new ScatterGatherFirstCompletedGroup(TimeSpan.FromSeconds(1), actor1.Path.ToString(), actor2.Path.ToString())));
routedActor.Tell(new Broadcast(1));
routedActor.Tell(new Broadcast("end"));
doneLatch.Ready(TimeSpan.FromSeconds(1));
counter1.Value.ShouldBe(1);
counter2.Value.ShouldBe(1);
}
开发者ID:rmiller1971,项目名称:akka.net,代码行数:18,代码来源:ScatterGatherFirstCompletedSpec.cs
示例14: BroadcastGroup_router_must_broadcast_message_using_Ask
public void BroadcastGroup_router_must_broadcast_message_using_Ask()
{
var doneLatch = new TestLatch(2);
var counter1 = new AtomicCounter(0);
var actor1 = Sys.ActorOf(Props.Create(() => new BroadcastTarget(doneLatch, counter1)));
var counter2 = new AtomicCounter(0);
var actor2 = Sys.ActorOf(Props.Create(() => new BroadcastTarget(doneLatch, counter2)));
var paths = new List<string> { actor1.Path.ToString(), actor2.Path.ToString() };
var routedActor = Sys.ActorOf(new BroadcastGroup(paths).Props());
routedActor.Ask(new Broadcast(1));
routedActor.Tell(new Broadcast("end"));
doneLatch.Ready(RemainingOrDefault);
counter1.Current.Should().Be(1);
counter2.Current.Should().Be(1);
}
开发者ID:Micha-kun,项目名称:akka.net,代码行数:20,代码来源:BroadcastSpec.cs
示例15: Random_must_be_able_to_shut_down_its_instance
public void Random_must_be_able_to_shut_down_its_instance()
{
const int routeeCount = 7;
var testLatch = new TestLatch(Sys, routeeCount);
var router = Sys.ActorOf(new RandomPool(routeeCount).Props(Props.Create(() => new HelloWorldActor(testLatch))));
router.Tell("hello", TestActor);
router.Tell("hello", TestActor);
router.Tell("hello", TestActor);
router.Tell("hello", TestActor);
router.Tell("hello", TestActor);
Within(TimeSpan.FromSeconds(2), () => {
ExpectMsg("world");
ExpectMsg("world");
ExpectMsg("world");
ExpectMsg("world");
ExpectMsg("world");
return true;
});
Sys.Stop(router);
testLatch.Ready(TimeSpan.FromSeconds(5));
}
开发者ID:ClusterReply,项目名称:akka.net,代码行数:23,代码来源:RandomSpec.cs
示例16: StopActor
public StopActor(int id, TestLatch shutdownLatch)
{
_id = id;
_shutdownLatch = shutdownLatch;
Receive<Stop>(s =>
{
if (s.Id == null || s.Id == _id)
{
Context.Stop(Self);
}
});
Receive<int>(n => n == _id, _ =>
{
});
ReceiveAny(x =>
{
Thread.Sleep(100 * _id);
Sender.Tell(_id);
});
}
开发者ID:Micha-kun,项目名称:akka.net,代码行数:24,代码来源:ScatterGatherFirstCompletedSpec.cs
示例17: Random_pool_must_be_able_to_shut_down_its_instance
public void Random_pool_must_be_able_to_shut_down_its_instance()
{
const int routeeCount = 7;
var testLatch = new TestLatch(routeeCount);
var actor = Sys.ActorOf(new RandomPool(routeeCount)
.Props(Props.Create(() => new HelloWorldActor(testLatch))), "random-shutdown");
actor.Tell("hello");
actor.Tell("hello");
actor.Tell("hello");
actor.Tell("hello");
actor.Tell("hello");
Within(TimeSpan.FromSeconds(2), () => {
for (int i = 1; i <= 5; i++)
{
ExpectMsg("world");
}
});
Sys.Stop(actor);
testLatch.Ready(5.Seconds());
}
开发者ID:Micha-kun,项目名称:akka.net,代码行数:24,代码来源:RandomSpec.cs
示例18: 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);
}
开发者ID:MaciekLesiczka,项目名称:akka.net,代码行数:36,代码来源:SmallestMailboxSpec.cs
示例19: BroadcastTarget
public BroadcastTarget(TestLatch latch, AtomicCounter counter)
{
_latch = latch;
_counter = counter;
}
开发者ID:rogeralsing,项目名称:akka.net,代码行数:5,代码来源:TailChoppingSpec.cs
示例20: Tail_chopping_router_must_deliver_a_broadcast_message_using_tell
public void Tail_chopping_router_must_deliver_a_broadcast_message_using_tell()
{
var doneLatch = new TestLatch(2);
var counter1 = new AtomicCounter(0);
var counter2 = new AtomicCounter(0);
var actor1 = Sys.ActorOf(Props.Create(() => new BroadcastTarget(doneLatch, counter1)), "Actor1");
var actor2 = Sys.ActorOf(Props.Create(() => new BroadcastTarget(doneLatch, counter2)), "Actor2");
var routedActor = Sys.ActorOf(Props.Create<TestActor>()
.WithRouter(new TailChoppingGroup(new[] { actor1.Path.ToString(), actor2.Path.ToString() }, TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(100))
));
routedActor.Tell(new Broadcast(1));
routedActor.Tell(new Broadcast("end"));
doneLatch.Ready(TimeSpan.FromSeconds(1));
counter1.Current.ShouldBe(1);
counter2.Current.ShouldBe(1);
}
开发者ID:rogeralsing,项目名称:akka.net,代码行数:21,代码来源:TailChoppingSpec.cs
注:本文中的Akka.TestKit.TestLatch类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论