Index: mojo/public/java/system/src/org/chromium/mojo/system/Core.java |
diff --git a/mojo/public/java/system/src/org/chromium/mojo/system/Core.java b/mojo/public/java/system/src/org/chromium/mojo/system/Core.java |
index 40e4be365d07249cf6d288fa4ecdb6d425992a4f..e5c6d08bcbf00bdb44262fdd36b2bb8a4b3a6ff4 100644 |
--- a/mojo/public/java/system/src/org/chromium/mojo/system/Core.java |
+++ b/mojo/public/java/system/src/org/chromium/mojo/system/Core.java |
@@ -3,6 +3,8 @@ |
// found in the LICENSE file. |
package org.chromium.mojo.system; |
+ |
+import java.util.List; |
/** |
* Core mojo interface giving access to the base operations. See |src/mojo/public/c/system/core.h| |
@@ -125,6 +127,142 @@ |
return mSatisfiableSignals; |
} |
} |
+ |
+ /** |
+ * Result for the |wait| method. |
+ */ |
+ public static class WaitResult { |
+ /** |
+ * The result of the wait method. |
+ * <p> |
+ * |MojoResult.OK| if some signal in |signals| was satisfied (or is already satisfied). |
+ * <p> |
+ * |MojoResult.DEADLINE_EXCEEDED| if the deadline has passed without any of the signals |
+ * being satisfied. |
+ * <p> |
+ * |MojoResult.CANCELLED| if |handle| is closed concurrently by another thread. |
+ * <p> |
+ * |MojoResult.FAILED_PRECONDITION| if it is or becomes impossible that any flag in |
+ * |signals| will ever be satisfied (for example, if the other endpoint is closed). |
+ */ |
+ private int mMojoResult; |
+ |
+ /** |
+ * The signaling state of handles. |
+ */ |
+ private HandleSignalsState mHandleSignalsState; |
+ |
+ /** |
+ * Returns the mojoResult. |
+ */ |
+ public int getMojoResult() { |
+ return mMojoResult; |
+ } |
+ |
+ /** |
+ * @param mojoResult the mojoResult to set |
+ */ |
+ public void setMojoResult(int mojoResult) { |
+ mMojoResult = mojoResult; |
+ } |
+ |
+ /** |
+ * Returns the handleSignalsState. |
+ */ |
+ public HandleSignalsState getHandleSignalsState() { |
+ return mHandleSignalsState; |
+ } |
+ |
+ /** |
+ * @param handleSignalsState the handleSignalsState to set |
+ */ |
+ public void setHandleSignalsState(HandleSignalsState handleSignalsState) { |
+ mHandleSignalsState = handleSignalsState; |
+ } |
+ } |
+ |
+ /** |
+ * Waits on the given |handle| until the state indicated by |signals| is satisfied or until |
+ * |deadline| has passed. |
+ * |
+ * @return a |WaitResult|. |
+ */ |
+ public WaitResult wait(Handle handle, HandleSignals signals, long deadline); |
+ |
+ /** |
+ * Result for the |waitMany| method. |
+ */ |
+ public static class WaitManyResult { |
+ |
+ /** |
+ * See |wait| for the different possible values. |
+ */ |
+ private int mMojoResult; |
+ |
+ /** |
+ * If |mojoResult| is |MojoResult.OK|, |handleIndex| is the index of the handle for which |
+ * some flag was satisfied (or is already satisfied). If |mojoResult| is |
+ * |MojoResult.CANCELLED| or |MojoResult.FAILED_PRECONDITION|, |handleIndex| is the index of |
+ * the handle for which the issue occurred. |
+ */ |
+ private int mHandleIndex; |
+ |
+ /** |
+ * The signaling state of handles. Will not be set if |mojoResult| is |
+ * |MOJO_RESULT_INVALID_ARGUMENT| or |MOJO_RESULT_RESOURCE_EXHAUSTED| |
+ */ |
+ private List<HandleSignalsState> mSignalStates; |
+ |
+ /** |
+ * Returns the mojoResult. |
+ */ |
+ public int getMojoResult() { |
+ return mMojoResult; |
+ } |
+ |
+ /** |
+ * @param mojoResult the mojoResult to set |
+ */ |
+ public void setMojoResult(int mojoResult) { |
+ mMojoResult = mojoResult; |
+ } |
+ |
+ /** |
+ * Returns the handleIndex. |
+ */ |
+ public int getHandleIndex() { |
+ return mHandleIndex; |
+ } |
+ |
+ /** |
+ * @param handleIndex the handleIndex to set |
+ */ |
+ public void setHandleIndex(int handleIndex) { |
+ mHandleIndex = handleIndex; |
+ } |
+ |
+ /** |
+ * Returns the signalStates. |
+ */ |
+ public List<HandleSignalsState> getSignalStates() { |
+ return mSignalStates; |
+ } |
+ |
+ /** |
+ * @param signalStates the signalStates to set |
+ */ |
+ public void setSignalStates(List<HandleSignalsState> signalStates) { |
+ mSignalStates = signalStates; |
+ } |
+ } |
+ |
+ /** |
+ * Waits on handle in |handles| for at least one of them to satisfy the associated |
+ * |HandleSignals|, or until |deadline| has passed. |
+ * |
+ * @returns a |WaitManyResult|. |
+ */ |
+ public WaitManyResult waitMany(List<Pair<Handle, HandleSignals>> handles, long deadline); |
/** |
* Creates a message pipe, which is a bidirectional communication channel for framed data (i.e., |