public AsyncSemaphoreContainer( IAsyncContainer <M, R> container, string semaphoreName) { _container = container; _semaphore = PipeManager.GetSemaphore(semaphoreName); }
protected void AddExecutor( bool defaultExecutor = false) { _currentExecutorSettings .ExecuteConditions = _conditionalQueueBuilder.GetFuncIfConditions(); if (defaultExecutor) { _conditionalQueueBuilder.SetDefault( _currentExecutorSettings, _currentContainer); } else { _conditionalQueueBuilder.Enque( _currentExecutorSettings, _currentContainer); } if (_executeIf) { _conditionalQueueBuilder.RemoveIfCondition(); _executeIf = false; } _skipCurrentExecutor = false; _currentContainer = null; _currentExecutorSettings = null; }
public static ValueTask RunAsync <T>(this IAsyncContainer <T> container, Action <T> action) { return(container.RunAsync((t, action) => { action(t); return new ValueTask <object?>(default(object)); }, action).AsValueTask()); }
public static ValueTask RunAsync <T>(this IAsyncContainer <T> container, Func <T, ValueTask> action) { return(container.RunAsync(async(t, action) => { await action(t); return default(object?); }, action).AsValueTask()); }
protected void StopWatch() { if (_skipCurrentExecutor) { return; } _currentContainer = new AsyncStopWatchContainer <M, R>(_currentContainer); }
public AsyncReTryContainer( IAsyncContainer <M, R> container, int count, int timeOutMilliseconds) { _container = container; _count = count; _timeOutMilliseconds = timeOutMilliseconds; }
protected void Retry( int count, int timeOutMilliseconds) { if (_skipCurrentExecutor) { return; } _currentContainer = new AsyncReTryContainer <M, R>(_currentContainer, count, timeOutMilliseconds); }
protected void StopWatch( bool condition) { if (_skipCurrentExecutor || !condition) { return; } _currentContainer = new AsyncStopWatchContainer <M, R>(_currentContainer); }
protected void SetExecutor( Func <M, IPipeCache, PipeResult <R> > executor, bool isDefault = false) { _skipCurrentExecutor = false; _currentContainer = new AsyncFuncCacheContainer <M, R>(executor); _currentExecutorSettings = isDefault ? new ExecutorSettings <M, R> { Label = "Default" } : new ExecutorSettings <M, R>(); }
protected void SetExecutor( Func <IAsyncExecutor <M, R> > executor, bool isDefault = false) { _skipCurrentExecutor = false; _currentContainer = new AsyncExecutorContainer <M, R>(executor); _currentExecutorSettings = isDefault ? new ExecutorSettings <M, R> { Label = "Default" } : new ExecutorSettings <M, R>(); }
protected void Restricted( int initialCount, string key) { if (_skipCurrentExecutor) { return; } PipeManager.SetSemaphore(initialCount, key); _currentContainer = new AsyncSemaphoreContainer <M, R>(_currentContainer, key); }
public AsyncStopWatchContainer(IAsyncContainer <M, R> container) { _container = container; }
public static ValueTask <TResult> RunAsync <T, TResult>(this IAsyncContainer <T> container, Func <T, TResult> func) { return(container.RunAsync((t, func) => new ValueTask <TResult>(func(t)), func)); }
public static ValueTask <TResult> RunAsync <T, TResult, TParam>(this IAsyncContainer <T> container, Func <T, TParam, ValueTask <TResult> > func, TParam param) { return(container.RunAsync(func, param)); }