| OLD | NEW |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library barback.pool; |
| 6 |
| 1 import 'dart:async'; | 7 import 'dart:async'; |
| 2 import 'dart:collection'; | 8 import 'dart:collection'; |
| 3 | 9 |
| 4 import 'package:stack_trace/stack_trace.dart'; | 10 import 'package:stack_trace/stack_trace.dart'; |
| 5 | 11 |
| 6 /// Manages an abstract pool of resources with a limit on how many may be in use | 12 /// Manages an abstract pool of resources with a limit on how many may be in use |
| 7 /// at once. | 13 /// at once. |
| 8 /// | 14 /// |
| 9 /// When a resource is needed, the user should call [checkOut]. When the | 15 /// When a resource is needed, the user should call [checkOut]. When the |
| 10 /// returned future completes with a [PoolResource], the resource may be | 16 /// returned future completes with a [PoolResource], the resource may be |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 /// Tells the parent [Pool] that the resource associated with this resource is | 130 /// Tells the parent [Pool] that the resource associated with this resource is |
| 125 /// no longer allocated, and that a new [PoolResource] may be checked out. | 131 /// no longer allocated, and that a new [PoolResource] may be checked out. |
| 126 void release() { | 132 void release() { |
| 127 if (_released) { | 133 if (_released) { |
| 128 throw new StateError("A PoolResource may only be released once."); | 134 throw new StateError("A PoolResource may only be released once."); |
| 129 } | 135 } |
| 130 _released = true; | 136 _released = true; |
| 131 _pool._onResourceReleased(); | 137 _pool._onResourceReleased(); |
| 132 } | 138 } |
| 133 } | 139 } |
| OLD | NEW |