Use the async package's new RestartableTimer class.

R=rnystrom@google.com

Review URL: https://codereview.chromium.org//1415223004 .
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9f74d07..dc852aa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.2.1
+
+* Internal changes only.
+
 ## 1.2.0
 
 * Add `Pool.close()`, which forbids new resource requests and releases all
diff --git a/lib/pool.dart b/lib/pool.dart
index 59b949e..ef38614 100644
--- a/lib/pool.dart
+++ b/lib/pool.dart
@@ -46,12 +46,14 @@
 
   /// The timeout timer.
   ///
-  /// If [_timeout] isn't null, this timer is set as soon as the resource limit
-  /// is reached and is reset every time an resource is released or a new
-  /// resource is requested. If it fires, that indicates that the caller became
-  /// deadlocked, likely due to files waiting for additional files to be read
-  /// before they could be closed.
-  Timer _timer;
+  /// This timer is canceled as long as the pool is below the resource limit.
+  /// It's reset once the resource limit is reached and again every time an
+  /// resource is released or a new resource is requested. If it fires, that
+  /// indicates that the caller became deadlocked, likely due to files waiting
+  /// for additional files to be read before they could be closed.
+  ///
+  /// This is `null` if this pool shouldn't time out.
+  RestartableTimer _timer;
 
   /// The amount of time to wait before timing out the pending resources.
   final Duration _timeout;
@@ -72,7 +74,13 @@
   /// all pending [request] futures will throw a [TimeoutException]. This is
   /// intended to avoid deadlocks.
   Pool(this._maxAllocatedResources, {Duration timeout})
-      : _timeout = 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.
+      _timer = new RestartableTimer(timeout, _onTimeout)..cancel();
+    }
+  }
 
   /// Request a [PoolResource].
   ///
@@ -190,11 +198,12 @@
 
   /// A resource has been requested, allocated, or released.
   void _resetTimer() {
-    if (_timer != null) _timer.cancel();
-    if (_timeout == null || _requestedResources.isEmpty) {
-      _timer = null;
+    if (_timer == null) return;
+
+    if (_requestedResources.isEmpty) {
+      _timer.cancel();
     } else {
-      _timer = new Timer(_timeout, _onTimeout);
+      _timer.reset();
     }
   }
 
diff --git a/pubspec.yaml b/pubspec.yaml
index 0013e9e..9635620 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,10 +1,10 @@
 name: pool
-version: 1.2.0
+version: 1.2.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.3.0"
+  async: "^1.4.0"
   stack_trace: ">=0.9.2 <2.0.0"
 environment:
   sdk: ">=1.9.0 <2.0.0"