Skip to content

Commit

Permalink
Release 3.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Serious-senpai committed Apr 11, 2024
1 parent 01eace0 commit 28d8e47
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 3.3.4
- Improve documentation and example

# 3.3.3
- Added support Dart 3
- Added support for Dart 3
- Minor documentation improvements

# 3.3.2
Expand Down
17 changes: 11 additions & 6 deletions example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,30 @@ import "package:async_locks/async_locks.dart";

class Program {
final lock = Lock();
final file = File("example.test");

Future<void> runFuture(int n) async {
var file = File("example.test");
// Concurrent write (in append mode) to the example file.
// Race conditions can occur without synchronization. Try removing the lock and see what happens.
await lock.run(() async => await file.writeAsString("Writing from Future-$n\n", mode: FileMode.append, flush: true));
}

Future<void> run() async {
// Wait for 4 futures
await Future.wait([runFuture(1), runFuture(2), runFuture(3), runFuture(4)]);
var file = File("example.test");

// Read and print file content to stdout
var content = await file.readAsString();
print(content);
}
}

void main() async {
// Create example file
var file = File("example.test");
await file.writeAsString("EXAMPLE FILE\n");

var program = Program();

// Write header to example file
await program.file.writeAsString("EXAMPLE FILE\n");

// Run futures with potential race conditions
await program.run();
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: async_locks
description: Synchronization primitives for asynchronous Dart code, inspired from Python
version: 3.3.3
version: 3.3.4
homepage: https://github.com/Serious-senpai/async-locks
repository: https://github.com/Serious-senpai/async-locks
issue_tracker: https://github.com/Serious-senpai/async-locks/issues
Expand Down

0 comments on commit 28d8e47

Please sign in to comment.