Manage a finite pool of resources in Dart
open sourceBSD-3-Clausefree
pool is a Dart package from the Dart team that limits how many resources are in use at once: a Pool class hands out a fixed number of resources, so callbacks run through withResource wait until one is free, which keeps concurrent file system or network requests under a limit. Resources can also be requested and released by hand, and a pool can time out when every resource stays checked out. Part of the dart-lang/tools monorepo, published on pub.dev by tools.dart.dev under the BSD 3-Clause licence.
Problems it solves
- limit how many files my Dart program opens at the same time
- cap concurrent HTTP requests in a Dart script
- run only N async tasks at once in Dart
Features
- Pool class that caps how many resources are allocated at once
- withResource runs a callback once a resource is free
- explicit PoolResource requests and releases
- optional timeout when every resource stays checked out
Alternatives
The same job
These do what pool does.
- synchronized Locks that stop asynchronous Dart code from running concurrently
