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

Unified Diff: samples/total/src/TotalRunner.dart

Issue 8317006: Added builtin native call to exit the running vm (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Renamed Runtime_Exit to Exit Created 9 years, 2 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
Index: samples/total/src/TotalRunner.dart
diff --git a/samples/total/src/TotalRunner.dart b/samples/total/src/TotalRunner.dart
index d34510c0db70d33ca2d798acd15e3b6eeb8be7f3..ef87b676ee6621aa45ab39d2fca86f1ec452b47e 100755
--- a/samples/total/src/TotalRunner.dart
+++ b/samples/total/src/TotalRunner.dart
@@ -9,42 +9,37 @@ typedef void ExitCallback(int status, String exitString);
void main() {
String SERVER_EXEC_PATH = './TotalServer.dart';
- String RESTART = "GRACEFUL RESTART!!";
- String EXIT = "GRACEFUL EXIT!!";
+ final int RESTART_STATUS = 42;
+ final int EXIT_STATUS = 0;
void keepServerRunning(int status, ServerRunner runner) {
- switch (runner.lastExitString) {
- case RESTART:
- runner.lastExitString = '';
+ switch (status) {
+ case RESTART_STATUS:
runner.run(keepServerRunning);
break;
- case EXIT:
+ case EXIT_STATUS:
break;
default:
- print("ERROR: exiting due to unknown condition. Exit status: $status."
- + " Exit string: '${runner.lastExitString}'");
+ print("ERROR: exiting due to unknown condition. Exit status: $status.");
break;
}
}
- new ServerRunner(SERVER_EXEC_PATH, [RESTART, EXIT]).run(keepServerRunning);
+ new ServerRunner(SERVER_EXEC_PATH).run(keepServerRunning);
}
class ServerRunner {
- List<String> _exitStrings;
String _serverMain;
// TODO: fix this to use a bigger buffer when streams work better
int _BUFSIZE = 1;
- String lastExitString;
-
// TODO: Release or Debug? We should be able to find automatically
static final DART_EXEC_PATH = '../../../runtime/out/Release_ia32/dart_bin';
static final CR = 0x0d;
static final LF = 0x0a;
- ServerRunner(String this._serverMain, List<String> this._exitStrings);
+ ServerRunner(String this._serverMain);
void run(ExitCallback exitCallback) {
Process dart = new Process(DART_EXEC_PATH, [_serverMain]);
@@ -78,21 +73,8 @@ class ServerRunner {
readSoFar.clear();
if (line.length != 0) {
print(line);
- _updateLastExitString(line);
}
}
});
}
-
- void _updateLastExitString(String line) {
- _exitStrings.some((String e) {
- if (line.contains(e, 0)) {
- lastExitString = e;
- return true;
- } else {
- return false;
- }
- });
- }
-
}

Powered by Google App Engine
This is Rietveld 408576698