Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: mojo/public/dart/src/handle.dart

Issue 728553002: Update mojo sdk to rev afb4440fd5a10cba980878c326180b7ad7960480 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/public/dart/src/data_pipe.dart ('k') | mojo/public/dart/src/message_pipe.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 part of core;
6
7
8 class _MojoHandleNatives {
9 static int close(int handle) native "MojoHandle_Close";
10 static int wait(int handle, int signals, int deadline)
11 native "MojoHandle_Wait";
12 static int waitMany(
13 List handles, List signals, int num_handles, int deadline)
14 native "MojoHandle_WaitMany";
15 }
16
17
18 class RawMojoHandle {
19 static const int INVALID = 0;
20 static const int DEADLINE_INDEFINITE = -1;
21
22 RawMojoHandle(this.h);
23
24 MojoResult close() {
25 int result = _MojoHandleNatives.close(h);
26 h = INVALID;
27 return new MojoResult(result);
28 }
29
30 MojoResult wait(int signals, int deadline) {
31 int result = _MojoHandleNatives.wait(h, signals, deadline);
32 return new MojoResult(result);
33 }
34
35 bool _ready(int signal) {
36 MojoResult res = wait(signal, 0);
37 switch (res) {
38 case MojoResult.OK:
39 return true;
40 case MojoResult.DEADLINE_EXCEEDED:
41 case MojoResult.CANCELLED:
42 case MojoResult.INVALID_ARGUMENT:
43 case MojoResult.FAILED_PRECONDITION:
44 return false;
45 default:
46 // Should be unreachable.
47 throw new Exception("Unreachable");
48 }
49 }
50
51 bool readyRead() => _ready(MojoHandleSignals.READABLE);
52 bool readyWrite() => _ready(MojoHandleSignals.WRITABLE);
53
54 static MojoResult waitMany(List<int> handles,
55 List<int> signals,
56 int deadline) {
57 if (handles.length != signals.length) {
58 return MojoResult.INVALID_ARGUMENT;
59 }
60 int result = _MojoHandleNatives.waitMany(
61 handles, signals, handles.length, deadline);
62 return new MojoResult(result);
63 }
64
65 static bool isValid(RawMojoHandle h) => (h.h != INVALID);
66
67 int h;
68 }
OLDNEW
« no previous file with comments | « mojo/public/dart/src/data_pipe.dart ('k') | mojo/public/dart/src/message_pipe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698