pooled_map 1.0.0 copy "pooled_map: ^1.0.0" to clipboard
pooled_map: ^1.0.0 copied to clipboard

An asynchronous map for Dart that locks keys, to avoid the Thundering Herd problem.

example/main.dart

import 'dart:async';
import 'package:pooled_map/pooled_map.dart';

main() async {
  // Even though we start 100000 simultaneous, asynchronous updates,
  // access is restricted to one-at-a-time.
  //
  // Thus, the output will be 100000.
  var i = 100000;
  var map = new PooledMap<String, int>(lockEntireMap: true);

  Future<int> increment() {
    return map.update('i', (i) => i + 1, defaultValue: () => 0);
  }

  var futures = new List<Future<int>>.generate(i, (_) => increment());
  await Future.wait(futures);
  var value = await map['i'];
  print('$value == 100000');
}
0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

An asynchronous map for Dart that locks keys, to avoid the Thundering Herd problem.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

pool

More

Packages that depend on pooled_map