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

Unified Diff: lib/src/util/async_thunk.dart

Issue 1260253005: Switch from AsyncThunk to AsyncMemoizer. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/runner/runner_suite.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/util/async_thunk.dart
diff --git a/lib/src/util/async_thunk.dart b/lib/src/util/async_thunk.dart
deleted file mode 100644
index a3589458afd67476afa6a0566e9d7b61989bff83..0000000000000000000000000000000000000000
--- a/lib/src/util/async_thunk.dart
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library test.util.async_thunk;
-
-import 'dart:async';
-
-/// A class for running an asynchronous method body exactly once and caching its
-/// result.
-///
-/// This should be stored as an instance variable, and [run] should be called
-/// when the method is invoked with the uncached method body. The first time, it
-/// runs the body; after that, it returns the future from the first run.
-class AsyncThunk<T> {
- /// The completer for the method's result.
- ///
- /// This will be `null` if [run] hasn't been called yet.
- Completer<T> _completer;
-
- /// Whether [run] has been called yet.
- bool get hasRun => _completer != null;
-
- /// Runs the method body, [fn], if it hasn't been run before.
- ///
- /// If [fn] has been run before, returns the original result.
- Future<T> run(fn()) {
- if (_completer == null) {
- _completer = new Completer.sync();
- new Future.sync(fn)
- .then(_completer.complete)
- .catchError(_completer.completeError);
- }
-
- return _completer.future;
- }
-}
« no previous file with comments | « lib/src/runner/runner_suite.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698