public SpecificThreadParticipant(IParticipantReference <TRequest, TResponse> func, int threadId, IWorkerPool workerPool, string name)
 {
     _func       = func;
     _threadId   = threadId;
     _workerPool = workerPool;
     _name       = name;
 }
Exemple #2
0
 public DispatchableScatter(IParticipantReference <TRequest, TResponse> func, Envelope <TRequest> request, Guid participantId, string name, IGatherReceiver <TResponse> scatter)
 {
     _func         = func;
     _request      = request;
     _name         = name;
     _scatter      = scatter;
     ParticipantId = participantId;
 }
Exemple #3
0
        public IThreadParticipantBuilder <TRequest, TResponse> InvokeEnvelope(Func <Envelope <TRequest>, TResponse> participant, bool useWeakReference = false)
        {
            Assert.ArgumentNotNull(participant, nameof(participant));
            ValidateDoesNotAlreadyHaveAction();
            var reference = CreateReference(participant, useWeakReference);

            _funcReference = reference;
            return(this);
        }
Exemple #4
0
        public ThreadPoolParticipant(IWorkerPool workerPool, IParticipantReference <TRequest, TResponse> action, string name)
        {
            Assert.ArgumentNotNull(workerPool, nameof(workerPool));
            Assert.ArgumentNotNull(action, nameof(action));

            _workerPool = workerPool;
            _action     = action;
            _name       = name;
        }
Exemple #5
0
 public static void GetResponses(Guid id, IParticipantReference <TRequest, TResponse> func, Envelope <TRequest> request, IGatherReceiver <TResponse> scatter, string name)
 {
     try
     {
         var response = func.Invoke(request);
         scatter.AddResponse(id, ScatterResponse <TResponse> .Success(id, name, response));
     }
     catch (Exception e)
     {
         scatter.AddResponse(id, ScatterResponse <TResponse> .Error(id, name, e));
     }
 }
Exemple #6
0
        private IParticipant <TRequest, TResponse> CreateParticipant(IParticipantReference <TRequest, TResponse> reference, DispatchThreadType dispatchType, int threadId, string name)
        {
            switch (dispatchType)
            {
            case DispatchThreadType.NoPreference:
                return(new AnyThreadParticipant <TRequest, TResponse>(reference, _workerPool, name));

            case DispatchThreadType.AnyWorkerThread:
                return(new AnyThreadParticipant <TRequest, TResponse>(reference, _workerPool, name));

            case DispatchThreadType.SpecificThread:
                return(new SpecificThreadParticipant <TRequest, TResponse>(reference, threadId, _workerPool, name));

            case DispatchThreadType.ThreadpoolThread:
                return(new ThreadPoolParticipant <TRequest, TResponse>(_workerPool, reference, name));

            case DispatchThreadType.Immediate:
                return(new ImmediateParticipant <TRequest, TResponse>(reference, name));

            default:
                return(new ImmediateParticipant <TRequest, TResponse>(reference, name));
            }
        }
Exemple #7
0
 public AnyThreadParticipant(IParticipantReference <TRequest, TResponse> func, IWorkerPool workerPool, string name)
 {
     _func       = func;
     _workerPool = workerPool;
     _name       = name;
 }
Exemple #8
0
 public ImmediateParticipant(IParticipantReference <TRequest, TResponse> func, string name)
 {
     _func = func;
     _name = name;
 }