Пример #1
0
 public Buffer(int size, ISubscriberPort <T> stage1, IPublisherPort <T[]> output)
 {
     _size   = size;
     _output = output;
     _buffer = new T[size];
     stage1.Subscribe(OnReceive);
 }
        /// <summary>
        /// Quick way to connect a Subscriber port to a Publisher port.  Useful connecting channels and Agents
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="port"></param>
        /// <param name="receive"></param>
        /// <returns></returns>
        public static IDisposable Connect <T>(this ISubscriberPort <T> port,
                                              IPublisherPort <T> receive)
        {
            var stub = StubFiber.StartNew();

            port.Subscribe(stub, receive.Publish);
            return(stub);
        }
Пример #3
0
 public ConcurrentComponent(IProcessor <TIn, TOut> processor,
                            ISubscriberPort <TIn> input,
                            IPublisherPort <TOut> output,
                            IPublisherPort <Exception> error,
                            FiberType type = FiberType.Pool) : base(new ExceptionHandlingExecutor(error.Publish), type)
 {
     processor.Exception += error.Publish;
     processor.Output    += output.Publish;
     processor.Initialize(this);
     input.Subscribe(Fiber, processor.Process);
 }
Пример #4
0
 public AsyncComponent(IAsyncProcessor <TIn, TOut> processor,
                       ISubscriberPort <TIn> input,
                       IPublisherPort <TOut> output,
                       IPublisherPort <Exception> error)
 {
     _processor           = processor;
     _output              = output;
     _error               = error;
     processor.Exception += error.Publish;
     processor.Output    += output.Publish;
     processor.Initialize(Fiber);
     input.Subscribe(Fiber, processor.Process);
 }
Пример #5
0
 public CompositeStage(IPublisherPort <TIn> input, ISubscriberPort <TOut> output, IDisposable disposables)
 {
     _input       = input;
     _output      = output;
     _disposables = disposables;
 }
Пример #6
0
 public SubscribeSocket(NetMQContext context, string address, Func <byte[], T> msgReceiver, IPublisherPort <T> output)
     : base(context, msgReceiver, output)
 {
     Socket = Context.CreateSocket(ZmqSocketType.Sub);
     Socket.Connect(address);
     Initialize();
 }
Пример #7
0
 protected ReceiveSocketBase(NetMQContext context, Func <byte[], T> receiver, IPublisherPort <T> output)
 {
     _msgReceiver = receiver;
     _output      = output;
     Context      = context;
 }
Пример #8
0
 public Agent(Action <T> handler, FiberType type = FiberType.Pool)
 {
     Fiber    = Fibrous.Fiber.StartNew(type);
     _channel = Fiber.NewPublishPort(handler);
 }
Пример #9
0
 /// <summary>
 /// Quick way to connect a Subscriber port to a Publisher port.  Useful connecting channels and Agents
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="port"></param>
 /// <param name="fiber"></param>
 /// <param name="receive"></param>
 /// <returns></returns>
 public static IDisposable Connect <T>(this ISubscriberPort <T> port,
                                       IFiber fiber,
                                       IPublisherPort <T> receive)
 {
     return(port.Subscribe(StubFiber.StartNew(), x => receive.Publish(x)));
 }
Пример #10
0
 public PullSocket(NetMQContext context, string address, Func <byte[], T> msgReceiver, IPublisherPort <T> output, bool useBind = true)
     : base(context, msgReceiver, output)
 {
     Socket = context.CreateSocket(ZmqSocketType.Pull);
     if (useBind)
     {
         Socket.Bind(address);
     }
     else
     {
         Socket.Connect(address);
     }
     Initialize();
 }
Пример #11
0
 /// <summary>
 ///     Quick way to connect a Subscriber port to a Publisher port.  Useful connecting channels and Agents
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="port"></param>
 /// <param name="receive"></param>
 /// <returns></returns>
 public static IDisposable Connect <T>(this ISubscriberPort <T> port,
                                       IPublisherPort <T> receive) =>
 port.Subscribe(receive.Publish);
Пример #12
0
 public void AddStage(IPublisherPort <Ordered <T> > stage) => _stages.Add(stage);
Пример #13
0
 protected AgentBase(FiberType type = FiberType.Pool)
 {
     Fiber    = Fibrous.Fiber.StartNew(type);
     _channel = Fiber.NewPublishPort <T>(Handle);
 }