コード例 #1
0
        public async Task RPC()
        {
            var reactorRepo     = ReactorRepository.CreateLocal(1);
            var responseReactor = new ResponseReactor();

            reactorRepo.Add(responseReactor);
            var requestReactor = new RPCReactor(reactorRepo.Resolve(responseReactor));

            reactorRepo.Add(requestReactor);

            await Task.Delay(100);

            Assert.True(requestReactor.State.ResponseGained);
        }
コード例 #2
0
        public async Task TwoReactors_Threads()
        {
            var repo     = ReactorRepository.CreateLocal(1, 0.01f, useTasks: false);
            var reactors = new ReactorBase[] { new Reactor1("1"),
                                               new Reactor1("2") };

            repo.Add(reactors[0]);
            repo.Add(reactors[1]);

            for (int i = 0; i < 20; i++)
            {
                reactors[i % 2].Enqueue(null, new Event1(i.ToString()));
                await Task.Delay(10);
            }

            await Task.Delay(30);

            Assert.Equal("18", ((Reactor1)reactors[0]).State.Data);
            Assert.Equal("19", ((Reactor1)reactors[1]).State.Data);
        }