Chromium Code Reviews| 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..42757d91823b1623f9e6f824ac933e360df22dcc 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, |
|
zra
2015/01/07 15:56:28
Does the new call give any additional information,
jimbe
2015/01/08 17:11:28
The new call returns information in WaitManyResult
|
| 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,18 +255,11 @@ class MojoHandleWatcher { |
| _signals[idx] = MojoHandleSignals.toggleWrite(_signals[idx]); |
| } |
| - void _pruneClosedHandles() { |
| - 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); |
| + void _pruneClosedHandles(List<MojoHandleSignalsState> states) { |
| + for (var i=0; i<_handles.length; i++) { |
| + if (MojoHandleSignals.isPeerClosed(states[i].satisfied_signals)) { |
| + _close(_handles[i], pruning: true); |
|
zra
2015/01/07 15:56:28
_close() calls _removeHandle() which will mess up
jimbe
2015/01/08 17:11:28
Done.
|
| } |
| - _tempHandle.h = RawMojoHandle.INVALID; |
| - } |
| - for (var h in closed) { |
| - _close(h, pruning: true); |
| } |
| } |