-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
using var asyncLock = new ReentrantAsyncLock();
for (var i = 0; i < 1000; i++)
{
var raceCondition = 0;
// You can acquire the lock asynchronously
await asyncLock.AcquireAsync(async () =>
{
await Task.WhenAll(
Task.Run(async () =>
{
// The lock is reentrant
await asyncLock.AcquireAsync(async () =>
{
// The lock provides mutual exclusion
raceCondition++;
await Task.CompletedTask;
});
}),
Task.Run(async () =>
{
await asyncLock.AcquireAsync(async () =>
{
raceCondition++;
await Task.CompletedTask;
});
})
);
});
if (raceCondition != 2)
throw new Exception();
}Need to update documentation accordingly.
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation