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

Side by Side Diff: pkg/barback/lib/src/pool.dart

Issue 92883002: Fix an incorrect method invocation in barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library barback.pool; 5 library barback.pool;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:stack_trace/stack_trace.dart'; 10 import 'package:stack_trace/stack_trace.dart';
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 _timer = null; 99 _timer = null;
100 } else { 100 } else {
101 _timer = new Timer(_timeout, _onTimeout); 101 _timer = new Timer(_timeout, _onTimeout);
102 } 102 }
103 } 103 }
104 104
105 /// Handles [_timer] timing out by causing all pending resource completers to 105 /// Handles [_timer] timing out by causing all pending resource completers to
106 /// emit exceptions. 106 /// emit exceptions.
107 void _onTimeout() { 107 void _onTimeout() {
108 for (var completer in _requestedResources) { 108 for (var completer in _requestedResources) {
109 completer.completeException("Pool deadlock: all resources have been " 109 completer.completeError("Pool deadlock: all resources have been "
110 "allocated for too long.", new Trace.current().vmTrace); 110 "allocated for too long.", new Trace.current().vmTrace);
111 } 111 }
112 _requestedResources.clear(); 112 _requestedResources.clear();
113 _timer = null; 113 _timer = null;
114 } 114 }
115 } 115 }
116 116
117 /// A member of a [Pool]. 117 /// A member of a [Pool].
118 /// 118 ///
119 /// A [PoolResource] is a token that indicates that a resource is allocated. 119 /// A [PoolResource] is a token that indicates that a resource is allocated.
120 /// When the associated resource is released, the user should call [release]. 120 /// When the associated resource is released, the user should call [release].
121 class PoolResource { 121 class PoolResource {
122 final Pool _pool; 122 final Pool _pool;
123 123
124 /// Whether [this] has been released yet. 124 /// Whether [this] has been released yet.
125 bool _released = false; 125 bool _released = false;
126 126
127 PoolResource._(this._pool); 127 PoolResource._(this._pool);
128 128
129 /// Tells the parent [Pool] that the resource associated with this resource is 129 /// Tells the parent [Pool] that the resource associated with this resource is
130 /// no longer allocated, and that a new [PoolResource] may be allocated. 130 /// no longer allocated, and that a new [PoolResource] may be allocated.
131 void release() { 131 void release() {
132 if (_released) { 132 if (_released) {
133 throw new StateError("A PoolResource may only be released once."); 133 throw new StateError("A PoolResource may only be released once.");
134 } 134 }
135 _released = true; 135 _released = true;
136 _pool._onResourceReleased(); 136 _pool._onResourceReleased();
137 } 137 }
138 } 138 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698