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

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

Issue 1426343002: EDK: Move mutex.*, cond_var.*, and thread_annotations.h to //mojo/edk/util. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: oops Created 5 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/edk/system/data_pipe_producer_dispatcher.cc ('k') | mojo/edk/system/dispatcher.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_DISPATCHER_H_ 5 #ifndef MOJO_EDK_SYSTEM_DISPATCHER_H_
6 #define MOJO_EDK_SYSTEM_DISPATCHER_H_ 6 #define MOJO_EDK_SYSTEM_DISPATCHER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <ostream> 12 #include <ostream>
13 #include <vector> 13 #include <vector>
14 14
15 #include "mojo/edk/embedder/platform_handle_vector.h" 15 #include "mojo/edk/embedder/platform_handle_vector.h"
16 #include "mojo/edk/system/handle_signals_state.h" 16 #include "mojo/edk/system/handle_signals_state.h"
17 #include "mojo/edk/system/memory.h" 17 #include "mojo/edk/system/memory.h"
18 #include "mojo/edk/system/mutex.h" 18 #include "mojo/edk/util/mutex.h"
19 #include "mojo/edk/util/ref_counted.h" 19 #include "mojo/edk/util/ref_counted.h"
20 #include "mojo/edk/util/ref_ptr.h" 20 #include "mojo/edk/util/ref_ptr.h"
21 #include "mojo/edk/util/thread_annotations.h"
21 #include "mojo/public/c/system/buffer.h" 22 #include "mojo/public/c/system/buffer.h"
22 #include "mojo/public/c/system/data_pipe.h" 23 #include "mojo/public/c/system/data_pipe.h"
23 #include "mojo/public/c/system/message_pipe.h" 24 #include "mojo/public/c/system/message_pipe.h"
24 #include "mojo/public/c/system/types.h" 25 #include "mojo/public/c/system/types.h"
25 #include "mojo/public/cpp/system/macros.h" 26 #include "mojo/public/cpp/system/macros.h"
26 27
27 namespace mojo { 28 namespace mojo {
28 29
29 namespace embedder { 30 namespace embedder {
30 class PlatformSharedBufferMapping; 31 class PlatformSharedBufferMapping;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 Channel* channel, 304 Channel* channel,
304 void* destination, 305 void* destination,
305 size_t* actual_size, 306 size_t* actual_size,
306 embedder::PlatformHandleVector* platform_handles) MOJO_NOT_THREAD_SAFE; 307 embedder::PlatformHandleVector* platform_handles) MOJO_NOT_THREAD_SAFE;
307 308
308 // This should be overridden to return true if/when there's an ongoing 309 // This should be overridden to return true if/when there's an ongoing
309 // operation (e.g., two-phase read/writes on data pipes) that should prevent a 310 // operation (e.g., two-phase read/writes on data pipes) that should prevent a
310 // handle from being sent over a message pipe (with status "busy"). 311 // handle from being sent over a message pipe (with status "busy").
311 virtual bool IsBusyNoLock() const MOJO_SHARED_LOCKS_REQUIRED(mutex_); 312 virtual bool IsBusyNoLock() const MOJO_SHARED_LOCKS_REQUIRED(mutex_);
312 313
313 Mutex& mutex() const MOJO_LOCK_RETURNED(mutex_) { return mutex_; } 314 util::Mutex& mutex() const MOJO_LOCK_RETURNED(mutex_) { return mutex_; }
314 315
315 private: 316 private:
316 FRIEND_REF_COUNTED_THREAD_SAFE(Dispatcher); 317 FRIEND_REF_COUNTED_THREAD_SAFE(Dispatcher);
317 friend class DispatcherTransport; 318 friend class DispatcherTransport;
318 319
319 // Closes the dispatcher. This must be done under lock, and unlike |Close()|, 320 // Closes the dispatcher. This must be done under lock, and unlike |Close()|,
320 // the dispatcher must not be closed already. (This is the "equivalent" of 321 // the dispatcher must not be closed already. (This is the "equivalent" of
321 // |CreateEquivalentDispatcherAndCloseNoLock()|, for situations where the 322 // |CreateEquivalentDispatcherAndCloseNoLock()|, for situations where the
322 // dispatcher must be disposed of instead of "transferred".) 323 // dispatcher must be disposed of instead of "transferred".)
323 void CloseNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); 324 void CloseNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 // |destination|. On failure, |*actual_size| should not be modified; however, 369 // |destination|. On failure, |*actual_size| should not be modified; however,
369 // the dispatcher will still be closed. 370 // the dispatcher will still be closed.
370 bool EndSerializeAndClose(Channel* channel, 371 bool EndSerializeAndClose(Channel* channel,
371 void* destination, 372 void* destination,
372 size_t* actual_size, 373 size_t* actual_size,
373 embedder::PlatformHandleVector* platform_handles) 374 embedder::PlatformHandleVector* platform_handles)
374 MOJO_NOT_THREAD_SAFE; 375 MOJO_NOT_THREAD_SAFE;
375 376
376 // This protects the following members as well as any state added by 377 // This protects the following members as well as any state added by
377 // subclasses. 378 // subclasses.
378 mutable Mutex mutex_; 379 mutable util::Mutex mutex_;
379 bool is_closed_ MOJO_GUARDED_BY(mutex_); 380 bool is_closed_ MOJO_GUARDED_BY(mutex_);
380 381
381 MOJO_DISALLOW_COPY_AND_ASSIGN(Dispatcher); 382 MOJO_DISALLOW_COPY_AND_ASSIGN(Dispatcher);
382 }; 383 };
383 384
384 // Wrapper around a |Dispatcher| pointer, while it's being processed to be 385 // Wrapper around a |Dispatcher| pointer, while it's being processed to be
385 // passed in a message pipe. See the comment about 386 // passed in a message pipe. See the comment about
386 // |Dispatcher::HandleTableAccess| for more details. 387 // |Dispatcher::HandleTableAccess| for more details.
387 // 388 //
388 // Note: This class is deliberately "thin" -- no more expensive than a 389 // Note: This class is deliberately "thin" -- no more expensive than a
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 422
422 // So logging macros and |DCHECK_EQ()|, etc. work. 423 // So logging macros and |DCHECK_EQ()|, etc. work.
423 inline std::ostream& operator<<(std::ostream& out, Dispatcher::Type type) { 424 inline std::ostream& operator<<(std::ostream& out, Dispatcher::Type type) {
424 return out << static_cast<int>(type); 425 return out << static_cast<int>(type);
425 } 426 }
426 427
427 } // namespace system 428 } // namespace system
428 } // namespace mojo 429 } // namespace mojo
429 430
430 #endif // MOJO_EDK_SYSTEM_DISPATCHER_H_ 431 #endif // MOJO_EDK_SYSTEM_DISPATCHER_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/data_pipe_producer_dispatcher.cc ('k') | mojo/edk/system/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698