Skip to content
 
 

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SharpReadWriteLock

A dumb lib to help manage read/write locks.

SharpReadWriteLock

Example

IReadWriteLocker locker = new ReadWriteLocker();

using (await locker.WriteLock("unique-key"))
{
    using (var l = await locker.ReadLock("unique-key", TimeSpan.FromSeconds(10)))
    {
        // Timeout, l == null, because there is currently a write lock.
    }

    using (var l = await locker.ReadLock("unique-key")) // Dead lock here.
    {
        
    }
}

using (await locker.ReadLock("unique-key"))
{
    using (var l = await locker.ReadLock("unique-key"))
    {
        // All good
    }

    using (var l = await locker.WriteLock("unique-key")) // Dead lock here, someone is currently reading.
    {
        
    }
}

About

A dumb lib to help manage read/write locks.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages