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

Side by Side Diff: mojo/public/cpp/system/wait.h

Issue 2744943002: Mojo: Move waiting APIs to public library (Closed)
Patch Set: . Created 3 years, 9 months 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/cpp/system/tests/wait_unittest.cc ('k') | mojo/public/cpp/system/wait.cc » ('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 2017 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 #ifndef MOJO_PUBLIC_CPP_SYSTEM_WAIT_H_
6 #define MOJO_PUBLIC_CPP_SYSTEM_WAIT_H_
7
8 #include <stddef.h>
9
10 #include "mojo/public/c/system/types.h"
11 #include "mojo/public/cpp/system/handle.h"
12 #include "mojo/public/cpp/system/system_export.h"
13
14 namespace mojo {
15
16 // Blocks the calling thread, waiting for one or more signals in |signals| to be
17 // become satisfied -- or for all of them to become unsatisfiable -- on the
18 // given Handle.
19 //
20 // If |signals_state| is non-null, |handle| is valid, the wait is not cancelled
21 // (see return values below), the last known signaling state of |handle| is
22 // written to |*signals_state| before returning.
23 //
24 // Return values:
25 // |MOJO_RESULT_OK| if one or more signals in |signals| has been raised on
26 // |handle| .
27 // |MOJO_RESULT_FAILED_PRECONDITION| if the state of |handle| changes such
28 // that no signals in |signals| can ever be raised again.
29 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle.
30 // |MOJO_RESULT_CANCELLED| if the wait was cancelled because |handle| was
31 // closed by some other thread while waiting.
32 MOJO_CPP_SYSTEM_EXPORT MojoResult
33 Wait(Handle handle,
34 MojoHandleSignals signals,
35 MojoHandleSignalsState* signals_state = nullptr);
36
37 // Waits on |handles[0]|, ..., |handles[num_handles-1]| until:
38 // - At least one handle satisfies a signal indicated in its respective
39 // |signals[0]|, ..., |signals[num_handles-1]|.
40 // - It becomes known that no signal in some |signals[i]| will ever be
41 // satisfied.
42 //
43 // This means that |WaitMany()| behaves as if |Wait()| were called on each
44 // handle/signals pair simultaneously, completing when the first |Wait()| would
45 // complete.
46 //
47 // If |signals_states| is non-null, all other arguments are valid, and the wait
48 // is not cancelled (see return values below), the last known signaling state of
49 // each Handle |handles[i]| is written to its corresponding entry in
50 // |signals_states[i]| before returning.
51 //
52 // Returns values:
53 // |MOJO_RESULT_OK| if one of the Handles in |handles| had one or more of its
54 // correpsonding signals satisfied. |*result_index| contains the index
55 // of the Handle in question if |result_index| is non-null.
56 // |MOJO_RESULT_FAILED_PRECONDITION| if one of the Handles in |handles|
57 // changes state such that its corresponding signals become permanently
58 // unsatisfiable. |*result_index| contains the index of the handle in
59 // question if |result_index| is non-null.
60 // |MOJO_RESULT_INVALID_ARGUMENT| if any Handle in |handles| is invalid,
61 // or if either |handles| or |signals| is null.
62 // |MOJO_RESULT_CANCELLED| if the wait was cancelled because a handle in
63 // |handles| was closed by some other thread while waiting.
64 // |*result_index| contains the index of the closed Handle if
65 // |result_index| is non-null.
66 MOJO_CPP_SYSTEM_EXPORT MojoResult
67 WaitMany(const Handle* handles,
68 const MojoHandleSignals* signals,
69 size_t num_handles,
70 size_t* result_index = nullptr,
71 MojoHandleSignalsState* signals_states = nullptr);
72
73 } // namespace mojo
74
75 #endif // MOJO_PUBLIC_CPP_SYSTEM_WAIT_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/system/tests/wait_unittest.cc ('k') | mojo/public/cpp/system/wait.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698