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

Unified Diff: runtime/bin/process_impl.dart

Issue 8318009: Update the streams interfaces (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@ 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
« no previous file with comments | « runtime/bin/input_stream.dart ('k') | runtime/bin/socket_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_impl.dart
diff --git a/runtime/bin/process_impl.dart b/runtime/bin/process_impl.dart
index b121d2cece06d22bdd2004086834d22c20286273..98546472f5de45d479b160943e518217f7b2051b 100644
--- a/runtime/bin/process_impl.dart
+++ b/runtime/bin/process_impl.dart
@@ -42,8 +42,10 @@ class _Process implements Process {
// Setup an exit handler to handle internal cleanup and possible
// callback when a process terminates.
_exitHandler.setDataHandler(() {
- List<int> buffer = new List<int>(8);
- SocketInputStream input = _exitHandler.inputStream;
+ final int EXIT_DATA_SIZE = 8;
+ List<int> exitDataBuffer = new List<int>(EXIT_DATA_SIZE);
+ InputStream input = _exitHandler.inputStream;
+ int exitDataRead = 0;
int exitCode(List<int> ints) {
return ints[4] + (ints[5] << 8) + (ints[6] << 16) + (ints[7] << 24);
@@ -54,20 +56,19 @@ class _Process implements Process {
}
void handleExit() {
- _processExit(exitPid(buffer));
+ _processExit(exitPid(exitDataBuffer));
if (_exitHandlerCallback != null) {
- _exitHandlerCallback(exitCode(buffer));
+ _exitHandlerCallback(exitCode(exitDataBuffer));
}
}
- void readData() {
- handleExit();
+ void exitData() {
+ exitDataRead += input.readInto(
+ exitDataBuffer, exitDataRead, EXIT_DATA_SIZE - exitDataRead);
+ if (exitDataRead == EXIT_DATA_SIZE) handleExit();
}
- bool result = input.read(buffer, 0, 8, readData);
- if (result) {
- handleExit();
- }
+ input.dataHandler = exitData;
});
}
« no previous file with comments | « runtime/bin/input_stream.dart ('k') | runtime/bin/socket_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698