reader_writer_lock 0.2.1

  • Readme
  • Changelog
  • Installing
  • 70

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.2.1 #

  • Bug-fix.

0.2.0 #

  • Supporting upgrading reader-lock to writer-lock.

0.1.0 #

  • Remove unused dependencies.

0.0.1 #

  • First release.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  reader_writer_lock: ^0.2.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:reader_writer_lock/reader_writer_lock.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Mar 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Format lib/reader_writer_lock.dart.

Run dartfmt to format lib/reader_writer_lock.dart.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and reader_writer_lock.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.

The package description is too short. (-1 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0