private void RunMult(IFiberFactory factory, Func <IChannel <int> > queueFactory, int count, int wait1) { using AutoResetEvent wait = new AutoResetEvent(false); int hCount = 0; void Handler(int s) { int c = Interlocked.Increment(ref hCount); if (c == OperationsPerInvoke) { wait.Set(); } NOP(wait1 / 1000.0); } using IChannel <int> queue = queueFactory(); using IDisposable fibers = new Disposables(Enumerable.Range(0, count).Select(x => { IFiber fiber = factory.CreateFiber(); IDisposable sub = queue.Subscribe(fiber, Handler); return(fiber); })); for (int j = 1; j <= OperationsPerInvoke; j++) { queue.Publish(j); } WaitHandle.WaitAny(new WaitHandle[] { wait }); }
public RequestAgent(IFiberFactory factory, Action <IRequest <TRequest, TReply> > handler, Action <Exception> errorHandler = null) { Fiber = factory.CreateFiber(errorHandler); _channel = Fiber.NewRequestPort(handler); }
public Agent(IFiberFactory factory, Action <T> handler, Action <Exception> errorCallback = null) { _handler = handler; Fiber = errorCallback == null?factory.CreateFiber() : factory.CreateFiber(errorCallback); }
protected UntypedActor(IFiberFactory factory = null) { Fiber = factory?.CreateFiber(OnError) ?? new Fiber(OnError); _tellChannel = Fiber.NewChannel <object>(Receive); _askChannel = Fiber.NewRequestPort <object, object>(OnRequest); }
public ChannelAgent(IFiberFactory factory, IChannel <T> channel, Action <T> handler, Action <Exception> errorCallback = null) { Fiber = factory.CreateFiber(errorCallback); channel.Subscribe(Fiber, handler); }