Index: mojo/public/java/src/org/chromium/mojo/system/AsyncWaiter.java |
diff --git a/mojo/public/java/src/org/chromium/mojo/system/AsyncWaiter.java b/mojo/public/java/src/org/chromium/mojo/system/AsyncWaiter.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a6dbb44b8a21df0899973f10af39988e87ac6a6a |
--- /dev/null |
+++ b/mojo/public/java/src/org/chromium/mojo/system/AsyncWaiter.java |
@@ -0,0 +1,36 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.mojo.system; |
+ |
+import org.chromium.mojo.system.Core.WaitFlags; |
+ |
+/** |
+ * Help classes allowing asynchronously calling wait on a background thread, and pass the result to |
bulach
2014/05/15 19:32:58
nit: the callback has also an error condition, so
rmcilroy
2014/05/15 22:36:51
Most of this is describes the asyncWait method. I
qsr
2014/05/19 12:12:09
Done.
|
+ * the given {@link AsyncWaiterCallback} on the current thread. Returns a {@link Cancellable} object |
+ * that can be used to stop waiting. This object becomes invalid once the callback runs. |
+ */ |
+public interface AsyncWaiter { |
+ |
+ /** |
+ * Allow to stop waiting. |
rmcilroy
2014/05/15 22:36:51
Allows cancelation of an asyncWait operation.
qsr
2014/05/19 12:12:09
Done.
|
+ */ |
+ interface Cancellable { |
+ /** |
+ * Stop waiting. Has no effect if the callback has already been called. Must be called from |
rmcilroy
2014/05/15 22:36:51
Cancels an asyncWait operation. Has no effect if
qsr
2014/05/19 12:12:09
Done.
|
+ * the same thread {@link AsyncWaiter#asyncWait(Handle, WaitFlags, long, |
+ * AsyncWaiterCallback)} has been called. |
+ */ |
+ void cancel(); |
+ } |
+ |
+ /** |
+ * Asynchronously call wait on a background thread, and pass the result of wait to the given |
+ * callback on the current thread. |
rmcilroy
2014/05/15 22:36:51
Asynchronously call wait on a background thread.
qsr
2014/05/19 12:12:09
Done.
|
+ */ |
+ Cancellable asyncWait(Handle handle, |
+ WaitFlags flags, long deadline, |
+ AsyncWaiterCallback callback); |
+ |
+} |