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

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

Issue 1785843002: [mojo] Implement pipe fusion API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 #ifndef MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ 5 #ifndef MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_
6 #define MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ 6 #define MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <queue> 10 #include <queue>
(...skipping 21 matching lines...) Expand all
32 // state, and one can never return to a disconnected once connected. 32 // state, and one can never return to a disconnected once connected.
33 // 33 //
34 // |pipe_id| is a unique identifier which can be used to track pipe endpoints 34 // |pipe_id| is a unique identifier which can be used to track pipe endpoints
35 // as they're passed around. |endpoint| is either 0 or 1 and again is only 35 // as they're passed around. |endpoint| is either 0 or 1 and again is only
36 // used for tracking pipes (one side is always 0, the other is always 1.) 36 // used for tracking pipes (one side is always 0, the other is always 1.)
37 MessagePipeDispatcher(NodeController* node_controller, 37 MessagePipeDispatcher(NodeController* node_controller,
38 const ports::PortRef& port, 38 const ports::PortRef& port,
39 uint64_t pipe_id, 39 uint64_t pipe_id,
40 int endpoint); 40 int endpoint);
41 41
42 // Begins a fuse operation for this pipe. Returns |true| if fusing is possible
43 // and |false| otherwise.
44 bool BeginFuse();
45
46 // Cancels a fuse operation for this pipe.
47 void CancelFuse();
48
49 // Fuses this pipe with |other|. |BeginFuse()| must have been called on both
50 // this and |other| first, and |Fuse()| itself must only be called on one of
51 // the two, passing the other as an argument. Both dispatchers are closed as a
52 // result of this operation regardless of whether it succeeds or fails.
53 bool CompleteFuse(MessagePipeDispatcher* other);
yzshen1 2016/03/11 17:17:20 It seems possible to only expose a single Fuse() m
54
42 // Dispatcher: 55 // Dispatcher:
43 Type GetType() const override; 56 Type GetType() const override;
44 MojoResult Close() override; 57 MojoResult Close() override;
45 MojoResult Watch(MojoHandleSignals signals, 58 MojoResult Watch(MojoHandleSignals signals,
46 const Watcher::WatchCallback& callback, 59 const Watcher::WatchCallback& callback,
47 uintptr_t context) override; 60 uintptr_t context) override;
48 MojoResult CancelWatch(uintptr_t context) override; 61 MojoResult CancelWatch(uintptr_t context) override;
49 MojoResult WriteMessage(const void* bytes, 62 MojoResult WriteMessage(const void* bytes,
50 uint32_t num_bytes, 63 uint32_t num_bytes,
51 const DispatcherInTransit* dispatchers, 64 const DispatcherInTransit* dispatchers,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 106
94 // These are safe to access from any thread without locking. 107 // These are safe to access from any thread without locking.
95 NodeController* const node_controller_; 108 NodeController* const node_controller_;
96 const ports::PortRef port_; 109 const ports::PortRef port_;
97 const uint64_t pipe_id_; 110 const uint64_t pipe_id_;
98 const int endpoint_; 111 const int endpoint_;
99 112
100 // Guards access to all the fields below. 113 // Guards access to all the fields below.
101 mutable base::Lock signal_lock_; 114 mutable base::Lock signal_lock_;
102 115
116 // Indicates if a fuse operation has been initiated for this pipe.
117 bool is_fusing_ = false;
118
103 // This is not the same is |port_transferred_|. It's only held true between 119 // This is not the same is |port_transferred_|. It's only held true between
104 // BeginTransit() and Complete/CancelTransit(). 120 // BeginTransit() and Complete/CancelTransit().
105 bool in_transit_ = false; 121 bool in_transit_ = false;
106 122
107 bool port_transferred_ = false; 123 bool port_transferred_ = false;
108 bool port_closed_ = false; 124 bool port_closed_ = false;
109 AwakableList awakables_; 125 AwakableList awakables_;
110 126
111 DISALLOW_COPY_AND_ASSIGN(MessagePipeDispatcher); 127 DISALLOW_COPY_AND_ASSIGN(MessagePipeDispatcher);
112 }; 128 };
113 129
114 } // namespace edk 130 } // namespace edk
115 } // namespace mojo 131 } // namespace mojo
116 132
117 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ 133 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698