| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package system | 5 package system |
| 6 | 6 |
| 7 import ( | 7 import "mojo/public/go/system/impl" |
| 8 » "unsafe" | |
| 9 | 8 |
| 10 » t "mojo/public/go/system/impl" | 9 type Core interface { |
| 11 ) | 10 » GetTimeTicksNow() int64 |
| 11 } |
| 12 | 12 |
| 13 // Core is an interface that defines the set of Mojo system APIs. | 13 var core *impl.CoreImpl |
| 14 type Core interface { | |
| 15 » // GetTimeTicksNow returns a monotonically increasing platform | |
| 16 » // dependent tick count representing "right now". Resolution | |
| 17 » // depends on the systemconfiguration. | |
| 18 » GetTimeTicksNow() t.MojoTimeTicks | |
| 19 | 14 |
| 20 » // Close closes the given handle. | 15 func init() { |
| 21 » Close(handle t.MojoHandle) (result t.MojoResult) | 16 core = &impl.CoreImpl{} |
| 17 } |
| 22 | 18 |
| 23 » // Wait waits on the given handle until a signal indicated by signals | 19 func GetCore() Core { |
| 24 » // is satisfied or it becomes known that no signal indicated by | 20 return core |
| 25 » // signals will ever be satisified or until deadline has passed. | 21 } |
| 26 » Wait(handle t.MojoHandle, signal t.MojoHandleSignals, deadline t.MojoDea
dline) (result t.MojoResult) | |
| 27 | |
| 28 » // WaitMany behaves as if Wait were called on each handle/signal pair | |
| 29 » // simultaneously and completing when the first Wait would complete. | |
| 30 » WaitMany(handles []t.MojoHandle, signals []t.MojoHandleSignals, deadline
t.MojoDeadline) (result t.MojoResult) | |
| 31 | |
| 32 » // CreateMessagePipe creates a message pipe which is a bidirectional | |
| 33 » // communication channel for framed data (i.e., messages). Messages | |
| 34 » // can contain plain data and/or Mojo handles. On success, it returns | |
| 35 » // handles to the two endpoints of the message pipe. | |
| 36 » CreateMessagePipe(opts *t.MessagePipeOptions) (result t.MojoResult, hand
le0 t.MojoHandle, handle1 t.MojoHandle) | |
| 37 | |
| 38 » // WriteMessage writes message data and optional attached handles to | |
| 39 » // the message pipe endpoint given by handle. On success the attached | |
| 40 » // handles will no longer be valid (ie: the receiver will receive | |
| 41 » // equivalent but logically different handles). | |
| 42 » WriteMessage(handle t.MojoHandle, msg []byte, attached []t.MojoHandle, f
lags t.MojoWriteMessageFlags) (result t.MojoResult) | |
| 43 | |
| 44 » // ReadMessage reads a message from the message pipe endpoint given | |
| 45 » // by handle with the specified flags. Returns the message data and | |
| 46 » // attached handles that were received and the number of bytes and | |
| 47 » // attached handles in the "next" message. | |
| 48 » ReadMessage(handle t.MojoHandle, flags t.MojoReadMessageFlags) (result t
.MojoResult, msg []byte, attached []t.MojoHandle, numBytes uint32, numHandles ui
nt32) | |
| 49 | |
| 50 » // CreateDataPipe creates a data pipe which is a unidirectional | |
| 51 » // communication channel for unframed data. On success, returns a | |
| 52 » // handle to the producer and consumer of the data pipe. | |
| 53 » CreateDataPipe(opts *t.DataPipeOptions) (result t.MojoResult, producer t
.MojoHandle, consumer t.MojoHandle) | |
| 54 | |
| 55 » // WriteData writes data to the data pipe producer handle with the | |
| 56 » // given flags. On success, returns the number of bytes that were | |
| 57 » // actually written. | |
| 58 » WriteData(producer t.MojoHandle, data []byte, flags t.MojoWriteDataFlags
) (result t.MojoResult, numBytes uint32) | |
| 59 | |
| 60 » // ReadData reads data from the data pipe consumer handle with the | |
| 61 » // given flags. On success, returns the data that was read. | |
| 62 » ReadData(consumer t.MojoHandle, flags t.MojoReadDataFlags) (result t.Moj
oResult, data []byte) | |
| 63 | |
| 64 » // CreateSharedBuffer creates a buffer of size numBytes that can be | |
| 65 » // shared between applications. One must call MapBuffer to access | |
| 66 » // the buffer. | |
| 67 » CreateSharedBuffer(opts *t.SharedBufferOptions, numBytes uint64) (result
t.MojoResult, handle t.MojoHandle) | |
| 68 | |
| 69 » // DuplicateBufferHandle duplicates the handle to a buffer. | |
| 70 » DuplicateBufferHandle(handle t.MojoHandle, opts *t.DuplicateBufferHandle
Options) (result t.MojoResult, duplicate t.MojoHandle) | |
| 71 | |
| 72 » // MapBuffer maps the requested part of the shared buffer given by | |
| 73 » // handle into memory with specified flags. On success, it returns | |
| 74 » // a pointer to the requested shared buffer. | |
| 75 » MapBuffer(handle t.MojoHandle, offset uint64, numBytes uint64, flags t.M
ojoMapBufferFlags) (result t.MojoResult, buffer unsafe.Pointer) | |
| 76 | |
| 77 » // UnmapBuffer unmaps a buffer pointer that was returned by MapBuffer. | |
| 78 » UnmapBuffer(buffer unsafe.Pointer) (result t.MojoResult) | |
| 79 } | |
| OLD | NEW |