dmutex 0.0.1 copy "dmutex: ^0.0.1" to clipboard
dmutex: ^0.0.1 copied to clipboard

Asynchronous locks and reentrant locks for Dart, enabling smooth concurrency control in your applications.

example/example.dart

import 'package:dmutex/dmutex.dart';

void main() async {
  // Example usage of the DLock class
  final dLock = DLock();

  await dLock.withLock(() async {
    print("Acquired DLock");
    await Future.delayed(Duration(seconds: 2));
    print("Released DLock");
  });

  // Example usage of the ReentrantDLock class
  final reentrantDLock = ReentrantDLock();

  await reentrantDLock.withLock(() async {
    print("Acquired ReentrantDLock");

    await reentrantDLock.withLock(() async {
      print("Acquired Nested ReentrantDLock");
      await Future.delayed(Duration(seconds: 1));
      print("Released Nested ReentrantDLock");
    });

    await Future.delayed(Duration(seconds: 2));
    print("Released ReentrantDLock");
  });

  print("Example completed");
}
2
likes
160
points
19
downloads

Publisher

unverified uploader

Weekly Downloads

Asynchronous locks and reentrant locks for Dart, enabling smooth concurrency control in your applications.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on dmutex