OLD | NEW |
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 #include "mojo/system/core.h" | 5 #include "mojo/system/core.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // INF. |Waiter| locks | 67 // INF. |Waiter| locks |
68 // | 68 // |
69 // Notes: | 69 // Notes: |
70 // - While holding a |Dispatcher| lock, you may not unconditionally attempt | 70 // - While holding a |Dispatcher| lock, you may not unconditionally attempt |
71 // to take another |Dispatcher| lock. (This has consequences on the | 71 // to take another |Dispatcher| lock. (This has consequences on the |
72 // concurrency semantics of |MojoWriteMessage()| when passing handles.) | 72 // concurrency semantics of |MojoWriteMessage()| when passing handles.) |
73 // Doing so would lead to deadlock. | 73 // Doing so would lead to deadlock. |
74 // - Locks at the "INF" level may not have any locks taken while they are | 74 // - Locks at the "INF" level may not have any locks taken while they are |
75 // held. | 75 // held. |
76 | 76 |
77 Core::HandleTableEntry::HandleTableEntry() | |
78 : busy(false) { | |
79 } | |
80 | |
81 Core::HandleTableEntry::HandleTableEntry( | |
82 const scoped_refptr<Dispatcher>& dispatcher) | |
83 : dispatcher(dispatcher), | |
84 busy(false) { | |
85 } | |
86 | |
87 Core::HandleTableEntry::~HandleTableEntry() { | |
88 DCHECK(!busy); | |
89 } | |
90 | |
91 Core::Core() { | 77 Core::Core() { |
92 } | 78 } |
93 | 79 |
94 Core::~Core() { | 80 Core::~Core() { |
95 } | 81 } |
96 | 82 |
97 MojoHandle Core::AddDispatcher( | 83 MojoHandle Core::AddDispatcher( |
98 const scoped_refptr<Dispatcher>& dispatcher) { | 84 const scoped_refptr<Dispatcher>& dispatcher) { |
99 base::AutoLock locker(handle_table_lock_); | 85 base::AutoLock locker(handle_table_lock_); |
100 return handle_table_.AddDispatcher(dispatcher); | 86 return handle_table_.AddDispatcher(dispatcher); |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 // |Wait()|/|WaitMany()| call. (Only after doing this can |waiter| be | 556 // |Wait()|/|WaitMany()| call. (Only after doing this can |waiter| be |
571 // destroyed, but this would still be required if the waiter were in TLS.) | 557 // destroyed, but this would still be required if the waiter were in TLS.) |
572 for (i = 0; i < num_added; i++) | 558 for (i = 0; i < num_added; i++) |
573 dispatchers[i]->RemoveWaiter(&waiter); | 559 dispatchers[i]->RemoveWaiter(&waiter); |
574 | 560 |
575 return rv; | 561 return rv; |
576 } | 562 } |
577 | 563 |
578 } // namespace system | 564 } // namespace system |
579 } // namespace mojo | 565 } // namespace mojo |
OLD | NEW |