public void Should_properly_invoke_the_message_receiver() { var fiber = new PoolFiber(); _engine = new DynamicRoutingEngine(fiber); _receivedA = new Future<A>(); _receivedB = new Future<B>(); _receivedC = new Future<C>(); _receivedMessageB = new Future<Message<B>>(); _receivedMessageC = new Future<Message<C>>(); _engine.Configure(x => { x.Receive<A>(_receivedA.Complete); x.Receive<B>(_receivedB.Complete); x.Receive<C>(_receivedC.Complete); x.Receive<Message<B>>(_receivedMessageB.Complete); x.Receive<Message<C>>(_receivedMessageC.Complete); }); _engine.Send(new B()); _engine.Send(new C()); _engine.Send(new B()); _engine.Send(new C()); fiber.Shutdown(5.Minutes()); }
// Henrik: I removed the finalizer, no unmanaged objects. See // http://blogs.msdn.com/b/tom/archive/2008/04/25/understanding-when-to-use-a-finalizer-in-your-net-class.aspx void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { if (_scheduler != null) { _scheduler.Stop(30.Seconds()); } _fiber.Shutdown(30.Seconds()); if (_producer != null) { _producer.Dispose(); } _serviceChannel = null; } _disposed = true; }
public void Should_properly_invoke_the_message_receiver() { var fiber = new PoolFiber(); _engine = new DynamicRoutingEngine(fiber); _receivedA = new Future <A>(); _receivedB = new Future <B>(); _receivedC = new Future <C>(); _receivedMessageB = new Future <Message <B> >(); _receivedMessageC = new Future <Message <C> >(); _engine.Configure(x => { x.Receive <A>(_receivedA.Complete); x.Receive <B>(_receivedB.Complete); x.Receive <C>(_receivedC.Complete); x.Receive <Message <B> >(_receivedMessageB.Complete); x.Receive <Message <C> >(_receivedMessageC.Complete); }); _engine.Send(new B()); _engine.Send(new C()); _engine.Send(new B()); _engine.Send(new C()); fiber.Shutdown(5.Minutes()); }
public void Should_prevent_new_actions_from_being_queued() { Fiber fiber = new PoolFiber(); var called = new Future<bool>(); fiber.Stop(); fiber.Add(() => called.Complete(true)); fiber.Shutdown(10.Seconds()); called.IsCompleted.ShouldBeFalse(); }
public void Should_prevent_new_actions_from_being_queued() { Fiber fiber = new PoolFiber(); var called = new Future <bool>(); fiber.Stop(); fiber.Add(() => called.Complete(true)); fiber.Shutdown(10.Seconds()); called.IsCompleted.ShouldBeFalse(); }
public void Should_result_in_no_waiting_actions_in_the_queue() { Fiber fiber = new PoolFiber(); var called = new Future<bool>(); 10.Times(() => fiber.Add(() => Thread.Sleep(100))); fiber.Add(() => called.Complete(true)); Stopwatch timer = Stopwatch.StartNew(); fiber.Shutdown(8.Seconds()); timer.Stop(); called.IsCompleted.ShouldBeTrue(); timer.ElapsedMilliseconds.ShouldBeLessThan(2000); }
public void Should_result_in_no_waiting_actions_in_the_queue() { Fiber fiber = new PoolFiber(); var called = new Future <bool>(); 10.Times(() => fiber.Add(() => Thread.Sleep(100))); fiber.Add(() => called.Complete(true)); Stopwatch timer = Stopwatch.StartNew(); fiber.Shutdown(8.Seconds()); timer.Stop(); called.IsCompleted.ShouldBeTrue(); timer.ElapsedMilliseconds.ShouldBeLessThan(2000); }