Skip to content

Commit

Permalink
chore: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
oscb committed May 9, 2023
1 parent 9e2e7cf commit 21519da
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/lib/utils/queue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ConcurrencyQueue<T> {
bool get _isLocked => (_lock == true);

bool _tryUnlock(Reducer<T> op) {
// If the file is unlo
// We process and lock right away if the file is unlocked
if (!_isLocked) {
_lock = true;
_process(op);
Expand All @@ -29,9 +29,11 @@ class ConcurrencyQueue<T> {

Future<T> _process(Reducer<T> op) async {
final result = await op.operation();
// The actual operation future is resolved here so the caller doesn't await for the full queue
op.completer.complete(result);
_lock = false;

// When the process completes we trigger the next one right away if there's already a queue
if (_queue.isNotEmpty) {
final nextOp = _queue.first;
if (_tryUnlock(nextOp)) {
Expand Down

0 comments on commit 21519da

Please sign in to comment.