Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Pool.withResource() should take () -> FutureOr<T>. #7

Merged
merged 2 commits into from
May 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.3.1

* Fix the type annotation of `Pool.withResource()` to indicate that it takes
`() -> FutureOr<T>`.

## 1.3.0

* Add a `Pool.done` getter that returns the same future returned by
Expand Down
6 changes: 3 additions & 3 deletions lib/pool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Pool {
/// Future.
///
/// The return value of [callback] is piped to the returned Future.
Future/*<T>*/ withResource/*<T>*/(/*=T*/ callback()) {
Future<T> withResource<T>(FutureOr<T> callback()) {
if (isClosed) {
throw new StateError(
"withResource() may not be called on a closed Pool.");
Expand All @@ -123,8 +123,8 @@ class Pool {
// synchronously in case the pool is closed immediately afterwards. Async
// functions have an asynchronous gap between calling and running the body,
// and [close] could be called during that gap. See #3.
return request().then/*<Future<T>>*/((resource) {
return new Future/*<T>*/.sync(callback).whenComplete(resource.release);
return request().then<Future<T>>((resource) {
return new Future<T>.sync(callback).whenComplete(resource.release);
});
}

Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: pool
version: 1.3.0
version: 1.3.1
author: Dart Team <misc@dartlang.org>
description: A class for managing a finite pool of resources.
homepage: https://github.com/dart-lang/pool
dependencies:
async: "^1.4.0"
stack_trace: ">=0.9.2 <2.0.0"
environment:
sdk: ">=1.9.0 <2.0.0"
sdk: ">=1.22.0 <2.0.0"
dev_dependencies:
fake_async: ">=0.1.0 <0.2.0"
test: ">=0.12.0 <0.13.0"