reader_writer_lock 0.2.1 copy "reader_writer_lock: ^0.2.1" to clipboard
reader_writer_lock: ^0.2.1 copied to clipboard

discontinued

Simple reader-writer-lock implementation upon mutex package

reader_writer_lock #

Simple reader-writer-lock implementation upon mutex package.

Usage #

The package realizes synchronized like syntax to reduce use of try-finally for releasing locks.

import 'package:reader_writer_lock/reader_writer_lock.dart';

final rwlock = ReaderWriterLock();

// reader-lock
await rwlock.readerLock(() async {
    // Do reader task here
});

// writer-lock
await rwlock.writerLock(() async {
    // Do writer task here
});

If you want to do some Test-and-Set operation, you can use readerLockUpgradable method to do so. It has a parameter, named upgrade and you can call the function to upgrader reader-lock to writer-lock.

import 'package:reader_writer_lock/reader_writer_lock.dart';

final rwlock = ReaderWriterLock();

// reader-lock
await rwlock.readerLockUpgradable((upgrade) async {
    // Do reader task here

    // Upgrade reader-lock to writer-lock
    await upgrade();

    // Do writer task here
});
0
likes
20
pub points
3%
popularity

Publisher

unverified uploader

Simple reader-writer-lock implementation upon mutex package

Repository (GitHub)
View/report issues

License

MIT (license)

More

Packages that depend on reader_writer_lock