public async Task <PipeResult <R> > RunAsync(M model, IPipeCache cache) { if (_executorInstance == null) { _executorInstance = _executor(); } return(await _executorInstance.ExecuteAsync(model, cache)); }
/// <summary> /// Asynchronously start the worker pool processing events in sequence. /// </summary> /// <param name="executor">providing threads for running the workers.</param> /// <returns>the <see cref="RingBuffer{TEvent}"/> used for the work queue.</returns> /// <exception cref="IllegalStateException">if the pool has already been started and not halted yet.</exception> public async Task <RingBuffer <T> > StartAsync(IAsyncExecutor executor) { if (Interlocked.Exchange(ref _started, 1) == 1) { throw new IllegalStateException("WorkerPool has already been started and cannot be restarted until halted."); } var cursor = _ringBuffer.GetCursor(); _workSequence.SetValue(cursor); foreach (var processor in _workProcessors) { processor.GetSequence().SetValue(cursor); await executor.ExecuteAsync(processor); } return(_ringBuffer); }
public async Task StartAsync(IAsyncExecutor executor) { await executor.ExecuteAsync(_processor); }