Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1051)

Unified Diff: packages/pool/lib/pool.dart

Issue 3015713002: Roll to pickup pool changes
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/pool/README.md ('k') | packages/pool/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/pool/lib/pool.dart
diff --git a/packages/pool/lib/pool.dart b/packages/pool/lib/pool.dart
index 04aaaea6590456dc4267dc1defe36bd6aea2015d..86f8363cedc6a3f6c31274a6870ce022127a96bc 100644
--- a/packages/pool/lib/pool.dart
+++ b/packages/pool/lib/pool.dart
@@ -78,8 +78,7 @@ class Pool {
/// If [timeout] is passed, then if that much time passes without any activity
/// all pending [request] futures will throw a [TimeoutException]. This is
/// intended to avoid deadlocks.
- Pool(this._maxAllocatedResources, {Duration timeout})
- : _timeout = timeout {
+ Pool(this._maxAllocatedResources, {Duration timeout}) : _timeout = timeout {
if (timeout != null) {
// Start the timer canceled since we only want to start counting down once
// we've run out of available resources.
@@ -140,21 +139,21 @@ class Pool {
///
/// This may be called more than once; it returns the same [Future] each time.
Future close() => _closeMemo.runOnce(() {
- if (_closeGroup != null) return _closeGroup.future;
+ if (_closeGroup != null) return _closeGroup.future;
- _resetTimer();
+ _resetTimer();
- _closeGroup = new FutureGroup();
- for (var callback in _onReleaseCallbacks) {
- _closeGroup.add(new Future.sync(callback));
- }
+ _closeGroup = new FutureGroup();
+ for (var callback in _onReleaseCallbacks) {
+ _closeGroup.add(new Future.sync(callback));
+ }
- _allocatedResources -= _onReleaseCallbacks.length;
- _onReleaseCallbacks.clear();
+ _allocatedResources -= _onReleaseCallbacks.length;
+ _onReleaseCallbacks.clear();
- if (_allocatedResources == 0) _closeGroup.close();
- return _closeGroup.future;
- });
+ if (_allocatedResources == 0) _closeGroup.close();
+ return _closeGroup.future;
+ });
final _closeMemo = new AsyncMemoizer();
/// If there are any pending requests, this will fire the oldest one.
@@ -183,8 +182,9 @@ class Pool {
_allocatedResources--;
if (_allocatedResources == 0) _closeGroup.close();
} else {
- _onReleaseCallbacks.add(
- Zone.current.bindCallback(onRelease, runGuarded: false));
+ var zone = Zone.current;
+ var registered = zone.registerCallback(onRelease);
+ _onReleaseCallbacks.add(() => zone.run(registered));
}
}
@@ -221,7 +221,8 @@ class Pool {
void _onTimeout() {
for (var completer in _requestedResources) {
completer.completeError(
- new TimeoutException("Pool deadlock: all resources have been "
+ new TimeoutException(
+ "Pool deadlock: all resources have been "
"allocated for too long.",
_timeout),
new Chain.current());
« no previous file with comments | « packages/pool/README.md ('k') | packages/pool/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698