< Summary

Information
Class: Elsa.Workflows.QueueBasedActivityScheduler
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Services/QueueBasedActivityScheduler.cs
Line coverage
87%
Covered lines: 7
Uncovered lines: 1
Coverable lines: 8
Total lines: 34
Line coverage: 87.5%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
get_HasAny()100%11100%
Schedule(...)100%11100%
Take()100%11100%
List()100%11100%
Any(...)100%210%
Find(...)100%11100%
Clear()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Services/QueueBasedActivityScheduler.cs

#LineLine coverage
 1using Elsa.Workflows.Models;
 2using JetBrains.Annotations;
 3
 4namespace Elsa.Workflows;
 5
 6/// <summary>
 7/// A FIFO queue based activity scheduler.
 8/// </summary>
 9[PublicAPI]
 10public class QueueBasedActivityScheduler : IActivityScheduler
 11{
 85512    private readonly Queue<ActivityWorkItem> _queue = new();
 13
 14    /// <inheritdoc />
 354015    public bool HasAny => _queue.Any();
 16
 17    /// <inheritdoc />
 314318    public void Schedule(ActivityWorkItem workItem) => _queue.Enqueue(workItem);
 19
 20    /// <inheritdoc />
 301921    public ActivityWorkItem Take() => _queue.Dequeue();
 22
 23    /// <inheritdoc />
 150424    public IEnumerable<ActivityWorkItem> List() => _queue;
 25
 26    /// <inheritdoc />
 027    public bool Any(Func<ActivityWorkItem, bool> predicate) => _queue.Any(predicate);
 28
 29    /// <inheritdoc />
 14630    public ActivityWorkItem? Find(Func<ActivityWorkItem, bool> predicate) => _queue.FirstOrDefault(predicate);
 31
 32    /// <inheritdoc />
 333    public void Clear() => _queue.Clear();
 34}