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

Side by Side Diff: lib/pool.dart

Issue 1949803002: Fix a new strong-mode error. (Closed) Base URL: git@github.com:dart-lang/pool@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 7
8 import 'package:async/async.dart'; 8 import 'package:async/async.dart';
9 import 'package:stack_trace/stack_trace.dart'; 9 import 'package:stack_trace/stack_trace.dart';
10 10
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 Future/*<T>*/ withResource/*<T>*/(/*=T*/ callback()) { 109 Future/*<T>*/ withResource/*<T>*/(/*=T*/ callback()) {
110 if (isClosed) { 110 if (isClosed) {
111 throw new StateError( 111 throw new StateError(
112 "withResource() may not be called on a closed Pool."); 112 "withResource() may not be called on a closed Pool.");
113 } 113 }
114 114
115 // We can't use async/await here because we need to start the request 115 // We can't use async/await here because we need to start the request
116 // synchronously in case the pool is closed immediately afterwards. Async 116 // synchronously in case the pool is closed immediately afterwards. Async
117 // functions have an asynchronous gap between calling and running the body, 117 // functions have an asynchronous gap between calling and running the body,
118 // and [close] could be called during that gap. See #3. 118 // and [close] could be called during that gap. See #3.
119 return request().then((resource) { 119 return request().then/*<Future<T>>*/((resource) {
120 return new Future.sync(callback).whenComplete(resource.release); 120 return new Future/*<T>*/.sync(callback).whenComplete(resource.release);
121 }); 121 });
122 } 122 }
123 123
124 /// Closes the pool so that no more resources are requested. 124 /// Closes the pool so that no more resources are requested.
125 /// 125 ///
126 /// Existing resource requests remain unchanged. 126 /// Existing resource requests remain unchanged.
127 /// 127 ///
128 /// Any resources that are marked as releasable using 128 /// Any resources that are marked as releasable using
129 /// [PoolResource.allowRelease] are released immediately. Once all resources 129 /// [PoolResource.allowRelease] are released immediately. Once all resources
130 /// have been released and any `onRelease` callbacks have completed, the 130 /// have been released and any `onRelease` callbacks have completed, the
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 /// produce additional information later on. For example, an isolate's task 258 /// produce additional information later on. For example, an isolate's task
259 /// may be complete, but it could still emit asynchronous errors. 259 /// may be complete, but it could still emit asynchronous errors.
260 void allowRelease(onRelease()) { 260 void allowRelease(onRelease()) {
261 if (_released) { 261 if (_released) {
262 throw new StateError("A PoolResource may only be released once."); 262 throw new StateError("A PoolResource may only be released once.");
263 } 263 }
264 _released = true; 264 _released = true;
265 _pool._onResourceReleaseAllowed(onRelease); 265 _pool._onResourceReleaseAllowed(onRelease);
266 } 266 }
267 } 267 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698