Esempio n. 1
0
 public DispatchableRequest(IListenerReference <TRequest, TResponse> func, Envelope <TRequest> envelope, Guid listenerId, IResponseReceiver <TResponse> request)
 {
     _func      = func;
     _envelope  = envelope;
     _request   = request;
     ListenerId = listenerId;
 }
Esempio n. 2
0
 public IThreadListenerBuilder <TRequest, TResponse> InvokeEnvelope(Func <Envelope <TRequest>, TResponse> listener, bool useWeakReference = false)
 {
     Assert.ArgumentNotNull(listener, nameof(listener));
     ValidateDoesNotAlreadyHaveAction();
     _funcReference = CreateReference(listener, useWeakReference);
     return(this);
 }
Esempio n. 3
0
 public IThreadListenerBuilder <TRequest, TResponse> ActivateAndInvoke <TService>(Func <TRequest, TService> createService, Func <TService, TRequest, TResponse> handler, bool cacheService = true)
     where TService : class
 {
     Assert.ArgumentNotNull(createService, nameof(createService));
     Assert.ArgumentNotNull(handler, nameof(handler));
     ValidateDoesNotAlreadyHaveAction();
     _funcReference = new ActivatedListenerReference <TRequest, TResponse, TService>(createService, handler, cacheService);
     return(this);
 }
Esempio n. 4
0
        private IListener <TRequest, TResponse> CreateListener(IListenerReference <TRequest, TResponse> reference, DispatchThreadType dispatchType, int threadId)
        {
            switch (dispatchType)
            {
            case DispatchThreadType.NoPreference:
                return(new AnyThreadListener <TRequest, TResponse>(reference, _workerPool));

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

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

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

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

            default:
                return(new ImmediateListener <TRequest, TResponse>(reference));
            }
        }
Esempio n. 5
0
 public AnyThreadListener(IListenerReference <TRequest, TResponse> func, IWorkerPool workerPool)
 {
     _func       = func;
     _workerPool = workerPool;
 }
Esempio n. 6
0
 public ImmediateListener(IListenerReference <TRequest, TResponse> func)
 {
     _func = func;
 }
Esempio n. 7
0
 public SpecificThreadListener(IListenerReference <TRequest, TResponse> func, int threadId, IWorkerPool workerPool)
 {
     _func       = func;
     _threadId   = threadId;
     _workerPool = workerPool;
 }