Class AsyncQueueBase<TItem>
Default implementation of IAsyncQueueBase<TItem> base functionality
Implements
Inherited Members
Namespace: SuperOffice.Threading
Assembly: SoCore.dll
Syntax
public abstract class AsyncQueueBase<TItem> : IAsyncQueueBase<TItem>
Type Parameters
| Name | Description |
|---|---|
| TItem | Item in the queue |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
Constructors
AsyncQueueBase(INSPrincipalAccessor, ILogger<AsyncQueueBase<TItem>>)
Default constructor
Declaration
protected AsyncQueueBase(INSPrincipalAccessor principalAccessor, ILogger<AsyncQueueBase<TItem>> logger)
Parameters
| Type | Name | Description |
|---|---|---|
| INSPrincipalAccessor | principalAccessor | |
| ILogger<AsyncQueueBase<TItem>> | logger |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
Fields
_dequeueLock
Default implementation of IAsyncQueueBase<TItem> base functionality
Declaration
protected readonly object _dequeueLock
Field Value
| Type | Description |
|---|---|
| object |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
_endOfProcessingCancellation
Default implementation of IAsyncQueueBase<TItem> base functionality
Declaration
protected readonly CancellationTokenSource _endOfProcessingCancellation
Field Value
| Type | Description |
|---|---|
| CancellationTokenSource |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
_itemsBeingProcessed
Default implementation of IAsyncQueueBase<TItem> base functionality
Declaration
protected readonly ConcurrentDictionary<Guid, AsyncQueueBase<TItem>.AsyncQueueItem> _itemsBeingProcessed
Field Value
| Type | Description |
|---|---|
| ConcurrentDictionary<Guid, AsyncQueueBase<TItem>.AsyncQueueItem> |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
_logger
Default implementation of IAsyncQueueBase<TItem> base functionality
Declaration
protected readonly ILogger<AsyncQueueBase<TItem>> _logger
Field Value
| Type | Description |
|---|---|
| ILogger<AsyncQueueBase<TItem>> |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
_principalAccessor
Default implementation of IAsyncQueueBase<TItem> base functionality
Declaration
protected readonly INSPrincipalAccessor _principalAccessor
Field Value
| Type | Description |
|---|---|
| INSPrincipalAccessor |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
Properties
HasItemsInTheQueue
True if there are items in the queue
Declaration
public abstract bool HasItemsInTheQueue { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
Methods
Enqueue(TItem)
Enqueue an item in the queue.
Declaration
public void Enqueue(TItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item |
Remarks
Information about current tenant and user is collected and stored with the item in the queue. This contextual settings are applied before the item is processed.
EnterQueueItemContext(AsyncQueueItem)
Default implementation of IAsyncQueueBase<TItem> base functionality
Declaration
protected IDisposable EnterQueueItemContext(AsyncQueueBase<TItem>.AsyncQueueItem queueItem)
Parameters
| Type | Name | Description |
|---|---|---|
| AsyncQueueBase<TItem>.AsyncQueueItem | queueItem |
Returns
| Type | Description |
|---|---|
| IDisposable |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
GetInnerQueueCompletionTasks()
Default implementation of IAsyncQueueBase<TItem> base functionality
Declaration
protected abstract IEnumerable<Task> GetInnerQueueCompletionTasks()
Returns
| Type | Description |
|---|---|
| IEnumerable<Task> |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
InnerEnqueue(AsyncQueueItem)
Default implementation of IAsyncQueueBase<TItem> base functionality
Declaration
protected abstract void InnerEnqueue(AsyncQueueBase<TItem>.AsyncQueueItem queItem)
Parameters
| Type | Name | Description |
|---|---|---|
| AsyncQueueBase<TItem>.AsyncQueueItem | queItem |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
ProcessItemsAsync(AsyncQueueProcessItemAsync<TItem>, CancellationToken)
Process items in the queue
Declaration
public Task ProcessItemsAsync(AsyncQueueProcessItemAsync<TItem> processor, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| AsyncQueueProcessItemAsync<TItem> | processor | Processor responsible for processing each item in the queue |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
ProcessNextItemAsync(AsyncQueueProcessItemAsync<TItem>, CancellationToken)
Process the next item in the queue. Wait for there to be an item in the queue.to start processing
Declaration
public abstract Task ProcessNextItemAsync(AsyncQueueProcessItemAsync<TItem> processor, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| AsyncQueueProcessItemAsync<TItem> | processor | Processor responsible for processing each item in the queue |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
Requeue(IAsyncQueueProcessItemContext<TItem>)
Default implementation of IAsyncQueueBase<TItem> base functionality
Declaration
public void Requeue(IAsyncQueueProcessItemContext<TItem> context)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncQueueProcessItemContext<TItem> | context |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
SignalProcessingCanceled()
Default implementation of IAsyncQueueBase<TItem> base functionality
Declaration
protected void SignalProcessingCanceled()
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
ToArray(bool)
Get a snapshot of all the items in the queue
Declaration
public abstract TItem[] ToArray(bool includeItemsBeingProcessed)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | includeItemsBeingProcessed | Include items currently being processed in the snapshot |
Returns
| Type | Description |
|---|---|
| TItem[] |
Remarks
Functionality used by the AsyncQueueProcessor<TItem> to process items in the queue.
WaitForItemsInQueueToBeProcessedAsync(CancellationToken)
Wait for all items currently in the queue or currently being processed to be processed.
Declaration
public Task WaitForItemsInQueueToBeProcessedAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Remarks
This method waits for items in the queue, items being process and any overflow tasks returned by the processor.
Exceptions
| Type | Condition |
|---|---|
| AggregateException | Thrown if any of the awaiting tasks throw an exception. |
| OperationCanceledException | Thrown if the operation is canceled. |