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

Unified Diff: mojo/public/dart/src/handle_watcher.dart

Issue 834283003: Update Dart bindings to support updated MojoWait and MojoWaitMany APIs. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Code review revisions Created 5 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 | « mojo/public/dart/src/handle.dart ('k') | mojo/public/dart/src/timer_queue.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/dart/src/handle_watcher.dart
diff --git a/mojo/public/dart/src/handle_watcher.dart b/mojo/public/dart/src/handle_watcher.dart
index 1af15fd9c4b9e752b922b7261d8f8f91fe9e47cc..2b504c8ca1db5cb1198fece911e9068f4853f286 100644
--- a/mojo/public/dart/src/handle_watcher.dart
+++ b/mojo/public/dart/src/handle_watcher.dart
@@ -99,21 +99,21 @@ class MojoHandleWatcher {
MojoHandleWatcher watcher = new MojoHandleWatcher(consumerHandle);
while (!watcher._shutdown) {
int deadline = watcher._processTimerDeadlines();
- int res = RawMojoHandle.waitMany(watcher._handles,
+ MojoWaitManyResult res = RawMojoHandle.waitMany(watcher._handles,
watcher._signals,
deadline);
- if (res == 0) {
+ if (res.result.isOk && res.index == 0) {
watcher._handleControlMessage();
- } else if (res > 0) {
- int handle = watcher._handles[res];
+ } else if (res.result.isOk && res.index > 0) {
+ int handle = watcher._handles[res.index];
// Route event.
- watcher._routeEvent(res);
+ watcher._routeEvent(res.index);
// Remove the handle from the list.
watcher._removeHandle(handle);
- } else if (res != MojoResult.kDeadlineExceeded) {
+ } else if (res.areSignalStatesValid) {
// Some handle was closed, but not by us.
- // We have to go through the list and find it.
- watcher._pruneClosedHandles();
+ // Find it and close it on our side.
+ watcher._pruneClosedHandles(res.states);
}
}
}
@@ -255,19 +255,18 @@ class MojoHandleWatcher {
_signals[idx] = MojoHandleSignals.toggleWrite(_signals[idx]);
}
- void _pruneClosedHandles() {
+ void _pruneClosedHandles(List<MojoHandleSignalsState> states) {
List<int> closed = new List();
- for (var h in _handles) {
- _tempHandle.h = h;
- MojoResult res = _tempHandle.wait(MojoHandleSignals.READWRITE, 0);
- if ((!res.isOk) && (!res.isDeadlineExceeded)) {
- closed.add(h);
+ for (var i=0; i<_handles.length; i++) {
+ if (MojoHandleSignals.isPeerClosed(states[i].satisfied_signals)) {
+ closed.add(_handles[i]);
}
- _tempHandle.h = RawMojoHandle.INVALID;
}
for (var h in closed) {
- _close(h, pruning: true);
+ _close(h, pruning: true);
}
+ // _close updated the _handles array, so at this point the _handles array
+ // and the signals array are mismatched.
zra 2015/01/08 17:23:11 This is not correct. _close() calls _removeHandle(
jimbe 2015/01/08 17:38:21 Poor choice of words. There are two separate signa
}
void _shutdownHandleWatcher() {
« no previous file with comments | « mojo/public/dart/src/handle.dart ('k') | mojo/public/dart/src/timer_queue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698