Skip to content

Instantly share code, notes, and snippets.

@stevejgordon
Created October 7, 2020 12:44
Show Gist options
  • Select an option

  • Save stevejgordon/2a9dae86170e88d522195e564198d4e5 to your computer and use it in GitHub Desktop.

Select an option

Save stevejgordon/2a9dae86170e88d522195e564198d4e5 to your computer and use it in GitHub Desktop.
if (blockedReader != null)
{
// Complete the reader. It's possible the reader was canceled, in which
// case we loop around to try everything again.
if (blockedReader.TrySetResult(item))
{
return true;
}
}
else
{
// Wake up all of the waiters. Since we've released the lock, it's possible
// we could cause some spurious wake-ups here, if we tell a waiter there's
// something available but all data has already been removed. It's a benign
// race condition, though, as consumers already need to account for such things.
ChannelUtilities.WakeUpWaiters(ref waitingReadersTail, result: true);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment