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

Side by Side Diff: mojo/edk/system/awakable.h

Issue 2076263003: Plumb the handle signals state to Awakable::Awake(). (Closed) Base URL: https://github.com/domokit/mojo.git@work794_wait_set_4.2
Patch Set: Created 4 years, 6 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/edk/system/async_waiter.cc ('k') | mojo/edk/system/awakable.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef MOJO_EDK_SYSTEM_AWAKABLE_H_ 5 #ifndef MOJO_EDK_SYSTEM_AWAKABLE_H_
6 #define MOJO_EDK_SYSTEM_AWAKABLE_H_ 6 #define MOJO_EDK_SYSTEM_AWAKABLE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "mojo/edk/system/handle_signals_state.h"
10 #include "mojo/public/c/system/result.h" 11 #include "mojo/public/c/system/result.h"
11 12
12 namespace mojo { 13 namespace mojo {
13 namespace system { 14 namespace system {
14 15
15 // An interface for things that may be awoken. E.g., |Waiter| is an 16 // An interface for things that may be awoken. E.g., |Waiter| is an
16 // implementation that blocks while waiting to be awoken. 17 // implementation that blocks while waiting to be awoken.
17 class Awakable { 18 class Awakable {
18 public: 19 public:
20 enum class AwakeReason { SATISFIED, UNSATISFIABLE, CANCELLED };
21
22 // Helper function that translates:
23 // - |AwakeReason::SATISFIED| -> |MOJO_RESULT_OK|,
24 // - |AwakeReason::UNSATISFIABLE| -> |MOJO_RESULT_FAILED_PRECONDITION|, and
25 // - |AwakeReason::CANCELLED| -> |MOJO_RESULT_CANCELLED|.
26 static MojoResult MojoResultForAwakeReason(AwakeReason reason);
27
19 // |Awake()| must satisfy the following contract: 28 // |Awake()| must satisfy the following contract:
20 // - It must be thread-safe. 29 // - It must be thread-safe.
21 // - Since it is called with a mutex held, it must not call anything that 30 // - Since it is called with a mutex held, it must not call anything that
22 // takes "non-terminal" locks, i.e., those which are always safe to take. 31 // takes "non-terminal" locks, i.e., those which are always safe to take.
23 // - It should return false if it must not be called again for the same 32 // - It should return false if it must not be called again for the same
24 // reason (e.g., for the same call to |AwakableList::Add()|). 33 // reason (e.g., for the same call to |AwakableList::Add()|).
25 virtual bool Awake(MojoResult result, uint64_t context) = 0; 34 virtual bool Awake(uint64_t context,
35 AwakeReason reason,
36 const HandleSignalsState& signals_state) = 0;
26 37
27 protected: 38 protected:
28 Awakable() {} 39 Awakable() {}
29 virtual ~Awakable() {} 40 virtual ~Awakable() {}
30 }; 41 };
31 42
32 } // namespace system 43 } // namespace system
33 } // namespace mojo 44 } // namespace mojo
34 45
35 #endif // MOJO_EDK_SYSTEM_AWAKABLE_H_ 46 #endif // MOJO_EDK_SYSTEM_AWAKABLE_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/async_waiter.cc ('k') | mojo/edk/system/awakable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698