Exemplo n.º 1
0
 public void TestTwoFibers()
 {
     FiberTester.TestPubSubWExtraFiber(ThreadFiber.StartNew(), ThreadFiber.StartNew());
     FiberTester.TestPubSubWExtraFiber(PoolFiber.StartNew(), ThreadFiber.StartNew());
     FiberTester.TestPubSubWExtraFiber(PoolFiber.StartNew(), PoolFiber.StartNew());
     FiberTester.TestPubSubWExtraFiber(PoolFiber.StartNew(), StubFiber.StartNew());
 }
Exemplo n.º 2
0
        public void OnlyOneConsumer()
        {
            using (var queues = new Disposables())
            {
                IChannel <int>      channel = new QueueChannel <int>();
                ConcurrentBag <int> results = new ConcurrentBag <int>();

                void OnReceive(int message)
                {
                    results.Add(message);
                }

                //Init executing Fibers
                for (int i = 0; i < 10; i++)
                {
                    IFiber threadFiber = ThreadFiber.StartNew();
                    queues.Add(threadFiber);
                    channel.Subscribe(threadFiber, OnReceive);
                }
                //Push messages
                for (int i = 0; i < 1000000; i++)
                {
                    channel.Publish(i);
                }
                Thread.Sleep(100);
                Assert.AreEqual(1000000, results.Count);
                var r1 = results.OrderBy(x => x).ToArray();
                for (int i = 0; i < 1000000; i++)
                {
                    Assert.AreEqual(i, r1[i]);
                }
            }
        }
Exemplo n.º 3
0
 public void TestBatching()
 {
     FiberTester.TestBatching(ThreadFiber.StartNew());
     FiberTester.TestBatching(PoolFiber.StartNew());
     FiberTester.TestBatching(StubFiber.StartNew());
     FiberTester.TestBatchingWithKey(ThreadFiber.StartNew());
     FiberTester.TestBatchingWithKey(PoolFiber.StartNew());
     FiberTester.TestBatchingWithKey(StubFiber.StartNew());
 }
Exemplo n.º 4
0
 public void TestReqReply()
 {
     FiberTester.TestReqReply1(ThreadFiber.StartNew());
     FiberTester.TestReqReply1(PoolFiber.StartNew());
     FiberTester.TestReqReply1(StubFiber.StartNew());
 }
Exemplo n.º 5
0
 public void TestPubSubWithFilter()
 {
     FiberTester.TestPubSubWithFilter(ThreadFiber.StartNew());
     FiberTester.TestPubSubWithFilter(PoolFiber.StartNew());
     FiberTester.TestPubSubWithFilter(StubFiber.StartNew());
 }
Exemplo n.º 6
0
 public void TestPubSubSimple()
 {
     FiberTester.TestPubSubSimple(ThreadFiber.StartNew());
     FiberTester.TestPubSubSimple(PoolFiber.StartNew());
     FiberTester.TestPubSubSimple(StubFiber.StartNew());
 }
Exemplo n.º 7
0
 public void InOrderExecution()
 {
     FiberTester.InOrderExecution(ThreadFiber.StartNew());
     FiberTester.InOrderExecution(PoolFiber.StartNew());
     FiberTester.InOrderExecution(StubFiber.StartNew());
 }