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

Side by Side Diff: mojo/public/c/system/wait_set.h

Issue 1461213002: WaitSet implementation for old EDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-waitset-skeleton
Patch Set: Fix windows build and style issues. Created 5 years 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 | « no previous file | mojo/public/platform/native/system_thunks.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // This file contains types/constants and functions specific to wait sets. 5 // This file contains types/constants and functions specific to wait sets.
6 // 6 //
7 // Note: This header should be compilable as C. 7 // Note: This header should be compilable as C.
8 8
9 #ifndef MOJO_PUBLIC_C_SYSTEM_WAIT_SET_H_ 9 #ifndef MOJO_PUBLIC_C_SYSTEM_WAIT_SET_H_
10 #define MOJO_PUBLIC_C_SYSTEM_WAIT_SET_H_ 10 #define MOJO_PUBLIC_C_SYSTEM_WAIT_SET_H_
(...skipping 20 matching lines...) Expand all
31 // been reached. 31 // been reached.
32 MOJO_SYSTEM_EXPORT MojoResult MojoCreateWaitSet( 32 MOJO_SYSTEM_EXPORT MojoResult MojoCreateWaitSet(
33 MojoHandle* wait_set_handle); // Out. 33 MojoHandle* wait_set_handle); // Out.
34 34
35 // Adds a wait on |handle| to |wait_set_handle|. 35 // Adds a wait on |handle| to |wait_set_handle|.
36 // 36 //
37 // A handle can only be added to any given wait set once, but may be added to 37 // A handle can only be added to any given wait set once, but may be added to
38 // any number of different wait sets. To modify the signals being waited for, 38 // any number of different wait sets. To modify the signals being waited for,
39 // the handle must first be removed, and then added with the new signals. 39 // the handle must first be removed, and then added with the new signals.
40 // 40 //
41 // If a handle is closed while still in the wait set, it is implicitly removed
42 // from the set after being returned from |MojoGetReadyHandles()| with the
43 // result |MOJO_RESULT_CANCELLED|.
44 //
41 // It is safe to add a handle to a wait set while performing a wait on another 45 // It is safe to add a handle to a wait set while performing a wait on another
42 // thread. If the added handle already has its signals satisfied, the waiting 46 // thread. If the added handle already has its signals satisfied, the waiting
43 // thread will be woken. 47 // thread will be woken.
44 // 48 //
45 // Returns: 49 // Returns:
46 // |MOJO_RESULT_OK| if |handle| was successfully added to |wait_set_handle|. 50 // |MOJO_RESULT_OK| if |handle| was successfully added to |wait_set_handle|.
47 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle, or 51 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle, or
48 // |wait_set_handle| is not a valid wait set. 52 // |wait_set_handle| is not a valid wait set.
49 // |MOJO_RESULT_ALREADY_EXISTS| if |handle| already exists in 53 // |MOJO_RESULT_ALREADY_EXISTS| if |handle| already exists in
50 // |wait_set_handle|. 54 // |wait_set_handle|.
(...skipping 22 matching lines...) Expand all
73 // Retrieves a set of ready handles from |wait_set_handle|. A handle is ready if 77 // Retrieves a set of ready handles from |wait_set_handle|. A handle is ready if
74 // at least of of the following is true: 78 // at least of of the following is true:
75 // - The handle's signals are satisfied. 79 // - The handle's signals are satisfied.
76 // - It becomes known that no signal for the handle will ever be satisfied. 80 // - It becomes known that no signal for the handle will ever be satisfied.
77 // - The handle is closed. 81 // - The handle is closed.
78 // 82 //
79 // A wait set may have ready handles when it satisfies the 83 // A wait set may have ready handles when it satisfies the
80 // |MOJO_HANDLE_SIGNAL_READABLE| signal. Since handles may be added and removed 84 // |MOJO_HANDLE_SIGNAL_READABLE| signal. Since handles may be added and removed
81 // from a wait set concurrently, it is possible for a wait set to satisfy 85 // from a wait set concurrently, it is possible for a wait set to satisfy
82 // |MOJO_HANDLE_SIGNAL_READABLE|, but not have any ready handles when 86 // |MOJO_HANDLE_SIGNAL_READABLE|, but not have any ready handles when
83 // |MojoGetReadyHandle()| is called. These spurious wake-ups must be gracefully 87 // |MojoGetReadyHandles()| is called. These spurious wake-ups must be gracefully
84 // handled. 88 // handled.
85 // 89 //
86 // |*count| on input, must contain the maximum number of ready handles to be 90 // |*count| on input, must contain the maximum number of ready handles to be
87 // returned. On output, it will contain the number of ready handles returned. 91 // returned. On output, it will contain the number of ready handles returned.
88 // 92 //
89 // |handles| must point to an array of size |*count| of |MojoHandle|. It will be 93 // |handles| must point to an array of size |*count| of |MojoHandle|. It will be
90 // populated with handles that are considered ready. The number of handles 94 // populated with handles that are considered ready. The number of handles
91 // returned will be in |*count|. 95 // returned will be in |*count|.
92 // 96 //
93 // |results| must point to an array of size |*count| of |MojoResult|. It will be 97 // |results| must point to an array of size |*count| of |MojoResult|. It will be
94 // populated with the wait result of the corresponding handle in |*handles|. 98 // populated with the wait result of the corresponding handle in |*handles|.
95 // Care should be taken that if a handle is closed on another thread, the handle 99 // Care should be taken that if a handle is closed on another thread, the handle
96 // would be invalid, but the result may not be |MOJO_RESULT_CANCELLED|. See 100 // would be invalid, but the result may not be |MOJO_RESULT_CANCELLED|. See
97 // documentation for |MojoWait()| for possible results. 101 // documentation for |MojoWait()| for possible results.
98 // 102 //
99 // |signals_state| (optional) if non-null, must point to an array of size 103 // |signals_state| (optional) if non-null, must point to an array of size
100 // |*count| of |MojoHandleSignalsState|. It will be populated with the signals 104 // |*count| of |MojoHandleSignalsState|. It will be populated with the signals
101 // state of the corresponding handle in |*handles|. See documentation for 105 // state of the corresponding handle in |*handles|. See documentation for
102 // |MojoHandleSignalsState|. 106 // |MojoHandleSignalsState| for more details about the meaning of each array
107 // entry. The array will always be updated for every returned handle.
103 // 108 //
104 // Mojo signals and satisfiability are logically 'level-triggered'. Therefore, 109 // Mojo signals and satisfiability are logically 'level-triggered'. Therefore,
105 // if a signal continues to be satisfied and is not removed from the wait set, 110 // if a signal continues to be satisfied and is not removed from the wait set,
106 // subsequent calls to |MojoGetReadyHandle()| will return the same handle. 111 // subsequent calls to |MojoGetReadyHandles()| will return the same handle.
107 // 112 //
108 // If multiple handles have their signals satisfied, the order in which handles 113 // If multiple handles have their signals satisfied, the order in which handles
109 // are returned is undefined. The same handle, if not removed, may be returned 114 // are returned is undefined. The same handle, if not removed, may be returned
110 // in consecutive calls. Callers must not rely on any fairness and handles 115 // in consecutive calls. Callers must not rely on any fairness and handles
111 // could be starved if not acted on. 116 // could be starved if not acted on.
112 // 117 //
113 // Returns: 118 // Returns:
114 // |MOJO_RESULT_OK| if ready handles are available. 119 // |MOJO_RESULT_OK| if ready handles are available.
115 // |MOJO_RESULT_INVALID_ARGUMENT| if |wait_set_handle| is not a valid wait 120 // |MOJO_RESULT_INVALID_ARGUMENT| if |wait_set_handle| is not a valid wait
116 // set, if |*count| is 0, or if either |count|, |handles|, or |results| is 121 // set, if |*count| is 0, or if either |count|, |handles|, or |results| is
117 // null. 122 // null.
118 // |MOJO_RESULT_SHOULD_WAIT| if there are no ready handles. 123 // |MOJO_RESULT_SHOULD_WAIT| if there are no ready handles.
119 MOJO_SYSTEM_EXPORT MojoResult MojoGetReadyHandles( 124 MOJO_SYSTEM_EXPORT MojoResult MojoGetReadyHandles(
120 MojoHandle wait_set_handle, 125 MojoHandle wait_set_handle,
121 uint32_t* count, // In/out. 126 uint32_t* count, // In/out.
122 MojoHandle* handles, // Out. 127 MojoHandle* handles, // Out.
123 MojoResult* results, // Out. 128 MojoResult* results, // Out.
124 struct MojoHandleSignalsState *signals_states); // Optional out. 129 struct MojoHandleSignalsState *signals_states); // Optional out.
125 130
126 #ifdef __cplusplus 131 #ifdef __cplusplus
127 } // extern "C" 132 } // extern "C"
128 #endif 133 #endif
129 134
130 #endif // MOJO_PUBLIC_C_SYSTEM_WAIT_SET_H_ 135 #endif // MOJO_PUBLIC_C_SYSTEM_WAIT_SET_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/public/platform/native/system_thunks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698