Skip to content

Commit

Permalink
Fixed a freeze bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
tosh-coding committed Jul 15, 2024
1 parent 390874d commit 59d4d51
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/AsyncFiberWorks/Fibers/AsyncFiber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,20 @@ bool TryDequeue(out Func<Task> result)
/// </summary>
async void Run()
{
while (TryDequeue(out var func))
while (true)
{
await _executor.Execute(func).ConfigureAwait(false);
}
lock (_lockObj)
{
_running = false;
while (TryDequeue(out var func))
{
await _executor.Execute(func).ConfigureAwait(false);
}
lock (_lockObj)
{
if (_queue.Count <= 0)
{
_running = false;
return;
}
}
}
}

Expand Down

0 comments on commit 59d4d51

Please sign in to comment.