コード例 #1
0
ファイル: Fiber.cs プロジェクト: JackWangCUMT/Fibrous
 //TODO:  add Queue
 /// <summary>
 /// Helper to create and start an IFiber by type
 /// </summary>
 /// <param name="type"></param>
 /// <param name="executor"></param>
 /// <returns></returns>
 public static IFiber StartNew(FiberType type, IExecutor executor = null)
 {
     if (executor == null) executor = new Executor();
     IFiber fiber = GetFromTyoe(type, executor);
     fiber.Start();
     return fiber;
 }
コード例 #2
0
ファイル: Fiber.cs プロジェクト: JackWangCUMT/Fibrous
 private static IFiber GetFromTyoe(FiberType type, IExecutor executor)
 {
     switch (type)
     {
         case FiberType.Thread:
             return new ThreadFiber(executor);
         case FiberType.Pool:
             return new PoolFiber(executor);
         case FiberType.Stub:
             return new StubFiber(executor);
         default:
             throw new ArgumentOutOfRangeException("type");
     }
 }
コード例 #3
0
 protected StageBase(FiberType type = FiberType.Pool, IExecutor executor = null)
 {
     Fiber = Fibrous.Fiber.StartNew(type, executor);
     Fiber.Subscribe(In, Receive);
 }
コード例 #4
0
 public FiberBuilderImpl(FiberType type)
 {
     _type = type;
 }
コード例 #5
0
 public static IFiberBuilder Create(FiberType type)
 {
     return(new FiberBuilderImpl(type));
 }
コード例 #6
0
ファイル: UntypedActor.cs プロジェクト: kouweizhong/Fibrous
 protected UntypedActor(FiberType type = FiberType.Pool)
 {
     Fiber = Fibrous.Fiber.StartNew(type, new ExceptionHandlingExecutor(OnError));
     Fiber.Subscribe(_tellChannel, Receive);
     _askChannel.SetRequestHandler(Fiber, OnRequest);
 }
コード例 #7
0
ファイル: Stage.cs プロジェクト: kouweizhong/Fibrous
 public Stage(Func <TIn, TOut> f, FiberType type = FiberType.Pool, IExecutor executor = null) : base(type, executor)
 {
     _f = f;
 }
コード例 #8
0
 protected AgentBase(FiberType type = FiberType.Pool)
 {
     Fiber    = Fibrous.Fiber.StartNew(type);
     _channel = Fiber.NewPublishPort <T>(Handle);
 }
コード例 #9
0
ファイル: RequestAgent.cs プロジェクト: kouweizhong/Fibrous
 public RequestAgent(Action <IRequest <TRequest, TReply> > handler, FiberType type = FiberType.Pool)
 {
     Fiber    = Fibrous.Fiber.StartNew(type);
     _channel = Fiber.NewRequestPort(handler);
 }
コード例 #10
0
ファイル: Agent.cs プロジェクト: kouweizhong/Fibrous
 public Agent(Action <T> handler, FiberType type = FiberType.Pool)
 {
     Fiber    = Fibrous.Fiber.StartNew(type);
     _channel = Fiber.NewPublishPort(handler);
 }
コード例 #11
0
 protected ConcurrentComponentBase(IExecutor executor = null, FiberType type = FiberType.Pool)
 {
     Fiber = Fibrous.Fiber.StartNew(type, executor);
 }
コード例 #12
0
ファイル: FiberBuilder.cs プロジェクト: chrisa23/Fibrous
 public FiberBuilderImpl(FiberType type)
 {
     _type = type;
 }
コード例 #13
0
ファイル: FiberBuilder.cs プロジェクト: chrisa23/Fibrous
 public static IFiberBuilder Create(FiberType type)
 {
     return new FiberBuilderImpl(type);
 }
コード例 #14
0
 /// <summary>
 /// Create and start an agent
 /// </summary>
 /// <param name="handler"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static IAgent <T> Start(Action <T> handler, FiberType type = FiberType.Pool)
 {
     return(new Agent <T>(handler, type));
 }
コード例 #15
0
 public Agent(Action <T> handler, FiberType type = FiberType.Pool) : base(type)
 {
     _handler = handler;
 }
コード例 #16
0
 protected RequestAgentBase(FiberType type = FiberType.Pool)
 {
     _fiber   = Fiber.StartNew(type);
     _channel = _fiber.NewRequestPort <TRequest, TReply>(Handle);
 }
コード例 #17
0
 public RequestAgent(Action <IRequest <TRequest, TReply> > handler, FiberType type = FiberType.Pool)
     : base(type)
 {
     _handler = handler;
 }
コード例 #18
0
ファイル: RequestAgent.cs プロジェクト: kouweizhong/Fibrous
 /// <summary>
 /// Create and start an agent
 /// </summary>
 /// <param name="handler"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static IRequestAgent <TRequest, TReply> Start(Action <IRequest <TRequest, TReply> > handler, FiberType type = FiberType.Pool)
 {
     return(new RequestAgent <TRequest, TReply>(handler, type));
 }
コード例 #19
0
 public ChannelAgent(IChannel <T> channel, Action <T> handler, FiberType type = FiberType.Pool)
 {
     Fiber = Fibrous.Fiber.StartNew(type);
     channel.Subscribe(Fiber, handler);
 }