Chromium Code Reviews| Index: mojo/public/java/src/org/chromium/mojo/system/Core.java |
| diff --git a/mojo/public/java/src/org/chromium/mojo/system/Core.java b/mojo/public/java/src/org/chromium/mojo/system/Core.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..34e5429dda0671a340addaddc557acca8742e079 |
| --- /dev/null |
| +++ b/mojo/public/java/src/org/chromium/mojo/system/Core.java |
| @@ -0,0 +1,131 @@ |
| +// 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 java.util.List; |
| + |
| +/** |
| + * Core mojo interface giving access to the base operations. |
| + */ |
| +public interface Core { |
| + |
| + /** |
| + * TODO(qsr): |
| + */ |
| + public static final long DEADLINE_INFINITE = -1; |
| + |
| + /** |
| + * Flag for the wait operations on handles. |
| + */ |
| + public static class WaitFlags extends Flags<WaitFlags> { |
| + /** |
| + * TODO(qsr): |
| + * |
| + * @param flags |
| + */ |
| + protected WaitFlags(int flags) { |
| + super(flags); |
| + } |
| + |
| + private static final int FLAG_NONE = 0; |
| + private static final int FLAG_READABLE = 1 << 0; |
| + private static final int FLAG_WRITABLE = 1 << 1; |
| + private static final int FLAG_ALL = ~0; |
| + |
| + /** |
| + * Change the readable bit of this flag. |
| + * |
| + * @param readable the new value of the readable bit. |
| + * @return this. |
| + */ |
| + public WaitFlags readable(boolean readable) { |
|
bulach
2014/04/14 17:39:56
nit: I think it's more common to have "set/get" pr
qsr
2014/04/15 08:37:37
The thing is this is more a builder than a simple
|
| + return setFlag(FLAG_READABLE, readable); |
| + } |
| + |
| + /** |
| + * Change the writable bit of this flag. |
| + * |
| + * @param writable the new value of the writable bit. |
| + * @return this. |
| + */ |
| + public WaitFlags writable(boolean writable) { |
| + return setFlag(FLAG_WRITABLE, writable); |
| + } |
| + |
| + /** |
| + * @return a flag with no bit set. |
| + */ |
| + public static WaitFlags none() { |
| + return new WaitFlags(FLAG_NONE); |
| + } |
| + |
| + /** |
| + * @return a flag with all bits set. |
| + */ |
| + public static WaitFlags all() { |
| + return new WaitFlags(FLAG_ALL); |
|
bulach
2014/04/14 17:39:56
what's the expected usage? in a tight loop, this w
qsr
2014/04/15 08:37:37
Are you speaking about this method in general or f
|
| + } |
| + } |
| + |
| + /** |
| + * TODO(qsr): |
| + * |
| + * @return TODO(qsr) |
| + */ |
| + public long getTimeTicksNow(); |
| + |
| + /** |
| + * TODO(qsr): |
| + * |
| + * @param handle |
| + * @param flags |
| + * @param deadline |
| + * @return TODO(qsr) |
| + */ |
| + public MojoResult wait(Handle handle, WaitFlags flags, long deadline); |
| + |
| + /** |
| + * TODO(qsr): Insert description here. |
| + */ |
| + public static class WaitManyResult { |
| + public MojoResult mojoResult; |
| + public int handleIndex; |
| + } |
| + |
| + /** |
| + * TODO(qsr) |
| + * |
| + * @param handles |
| + * @param deadline |
| + * @returns true if at least one handle is ready, false if the deadline expired. |
| + */ |
| + public WaitManyResult waitMany(List<Pair<Handle, WaitFlags>> handles, long deadline); |
| + |
| + /** |
| + * TODO(qsr) |
| + * |
| + * @return TODO(qsr) |
| + */ |
| + public Pair<MessagePipeHandle, MessagePipeHandle> createMessagePipe(); |
| + |
| + /** |
| + * TODO(qsr): |
| + * |
| + * @param options |
| + * @return TODO(qsr) |
| + */ |
| + public Pair<DataPipe.ProducerHandle, DataPipe.ConsumerHandle> createDataPipe( |
| + DataPipe.CreateOptions options); |
| + |
| + /** |
| + * TODO(qsr): |
| + * |
| + * @param options |
| + * @param numBytes |
| + * @return TODO(qsr) |
| + */ |
| + public SharedBufferHandle createSharedBuffer(SharedBufferHandle.CreateOptions options, |
| + long numBytes); |
| +} |