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

Unified Diff: utils/pub/utils.dart

Issue 12079112: Make a bunch of stuff in pub synchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix after merge. Created 7 years, 11 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 | « utils/pub/system_cache.dart ('k') | utils/pub/validator/compiled_dartdoc.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/utils.dart
diff --git a/utils/pub/utils.dart b/utils/pub/utils.dart
index 4cad26f587d5433bf405f8682210899903ac0d55..67dec0e5931684299166e75e91aafa608707f32f 100644
--- a/utils/pub/utils.dart
+++ b/utils/pub/utils.dart
@@ -145,6 +145,16 @@ String sha1(String source) {
return CryptoUtils.bytesToHex(sha.close());
}
+/// Invokes the given callback asynchronously. Returns a [Future] that completes
+/// to the result of [callback].
+///
+/// This is also used to wrap synchronous code that may thrown an exception to
+/// ensure that methods that have both sync and async code only report errors
+/// asynchronously.
+Future defer(callback()) {
+ return new Future.immediate(null).then((_) => callback());
+}
+
/// Returns a [Future] that completes in [milliseconds].
Future sleep(int milliseconds) {
var completer = new Completer();
« no previous file with comments | « utils/pub/system_cache.dart ('k') | utils/pub/validator/compiled_dartdoc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698