Index: mojo/edk/system/data_pipe.cc |
diff --git a/mojo/edk/system/data_pipe.cc b/mojo/edk/system/data_pipe.cc |
index cbacb89815c168f2f59ca40dcaad7cc2152af906..2f433bdf9a5cd9eb91638a4647868124d1ca40df 100644 |
--- a/mojo/edk/system/data_pipe.cc |
+++ b/mojo/edk/system/data_pipe.cc |
@@ -10,10 +10,10 @@ |
#include <limits> |
#include "base/logging.h" |
+#include "mojo/edk/system/awakable_list.h" |
#include "mojo/edk/system/configuration.h" |
#include "mojo/edk/system/memory.h" |
#include "mojo/edk/system/options_validation.h" |
-#include "mojo/edk/system/waiter_list.h" |
namespace mojo { |
namespace system { |
@@ -83,10 +83,10 @@ MojoResult DataPipe::ValidateCreateOptions( |
return MOJO_RESULT_OK; |
} |
-void DataPipe::ProducerCancelAllWaiters() { |
+void DataPipe::ProducerCancelAllAwakables() { |
base::AutoLock locker(lock_); |
DCHECK(has_local_producer_no_lock()); |
- producer_waiter_list_->CancelAllWaiters(); |
+ producer_awakable_list_->CancelAll(); |
} |
void DataPipe::ProducerClose() { |
@@ -94,13 +94,13 @@ void DataPipe::ProducerClose() { |
DCHECK(producer_open_); |
producer_open_ = false; |
DCHECK(has_local_producer_no_lock()); |
- producer_waiter_list_.reset(); |
+ producer_awakable_list_.reset(); |
// Not a bug, except possibly in "user" code. |
DVLOG_IF(2, producer_in_two_phase_write_no_lock()) |
<< "Producer closed with active two-phase write"; |
producer_two_phase_max_num_bytes_written_ = 0; |
ProducerCloseImplNoLock(); |
- AwakeConsumerWaitersForStateChangeNoLock( |
+ AwakeConsumerAwakablesForStateChangeNoLock( |
ConsumerGetHandleSignalsStateImplNoLock()); |
} |
@@ -132,7 +132,7 @@ MojoResult DataPipe::ProducerWriteData(UserPointer<const void> elements, |
HandleSignalsState new_consumer_state = |
ConsumerGetHandleSignalsStateImplNoLock(); |
if (!new_consumer_state.equals(old_consumer_state)) |
- AwakeConsumerWaitersForStateChangeNoLock(new_consumer_state); |
+ AwakeConsumerAwakablesForStateChangeNoLock(new_consumer_state); |
return rv; |
} |
@@ -159,10 +159,10 @@ MojoResult DataPipe::ProducerBeginWriteData( |
min_num_bytes_to_write); |
if (rv != MOJO_RESULT_OK) |
return rv; |
- // Note: No need to awake producer waiters, even though we're going from |
+ // Note: No need to awake producer awakables, even though we're going from |
// writable to non-writable (since you can't wait on non-writability). |
// Similarly, though this may have discarded data (in "may discard" mode), |
- // making it non-readable, there's still no need to awake consumer waiters. |
+ // making it non-readable, there's still no need to awake consumer awakables. |
DCHECK(producer_in_two_phase_write_no_lock()); |
return MOJO_RESULT_OK; |
} |
@@ -189,15 +189,15 @@ MojoResult DataPipe::ProducerEndWriteData(uint32_t num_bytes_written) { |
// Two-phase write ended even on failure. |
DCHECK(!producer_in_two_phase_write_no_lock()); |
// If we're now writable, we *became* writable (since we weren't writable |
- // during the two-phase write), so awake producer waiters. |
+ // during the two-phase write), so awake producer awakables. |
HandleSignalsState new_producer_state = |
ProducerGetHandleSignalsStateImplNoLock(); |
if (new_producer_state.satisfies(MOJO_HANDLE_SIGNAL_WRITABLE)) |
- AwakeProducerWaitersForStateChangeNoLock(new_producer_state); |
+ AwakeProducerAwakablesForStateChangeNoLock(new_producer_state); |
HandleSignalsState new_consumer_state = |
ConsumerGetHandleSignalsStateImplNoLock(); |
if (!new_consumer_state.equals(old_consumer_state)) |
- AwakeConsumerWaitersForStateChangeNoLock(new_consumer_state); |
+ AwakeConsumerAwakablesForStateChangeNoLock(new_consumer_state); |
return rv; |
} |
@@ -207,10 +207,10 @@ HandleSignalsState DataPipe::ProducerGetHandleSignalsState() { |
return ProducerGetHandleSignalsStateImplNoLock(); |
} |
-MojoResult DataPipe::ProducerAddWaiter(Waiter* waiter, |
- MojoHandleSignals signals, |
- uint32_t context, |
- HandleSignalsState* signals_state) { |
+MojoResult DataPipe::ProducerAddAwakable(Awakable* awakable, |
+ MojoHandleSignals signals, |
+ uint32_t context, |
+ HandleSignalsState* signals_state) { |
base::AutoLock locker(lock_); |
DCHECK(has_local_producer_no_lock()); |
@@ -226,15 +226,15 @@ MojoResult DataPipe::ProducerAddWaiter(Waiter* waiter, |
return MOJO_RESULT_FAILED_PRECONDITION; |
} |
- producer_waiter_list_->AddWaiter(waiter, signals, context); |
+ producer_awakable_list_->Add(awakable, signals, context); |
return MOJO_RESULT_OK; |
} |
-void DataPipe::ProducerRemoveWaiter(Waiter* waiter, |
- HandleSignalsState* signals_state) { |
+void DataPipe::ProducerRemoveAwakable(Awakable* awakable, |
+ HandleSignalsState* signals_state) { |
base::AutoLock locker(lock_); |
DCHECK(has_local_producer_no_lock()); |
- producer_waiter_list_->RemoveWaiter(waiter); |
+ producer_awakable_list_->Remove(awakable); |
if (signals_state) |
*signals_state = ProducerGetHandleSignalsStateImplNoLock(); |
} |
@@ -244,10 +244,10 @@ bool DataPipe::ProducerIsBusy() const { |
return producer_in_two_phase_write_no_lock(); |
} |
-void DataPipe::ConsumerCancelAllWaiters() { |
+void DataPipe::ConsumerCancelAllAwakables() { |
base::AutoLock locker(lock_); |
DCHECK(has_local_consumer_no_lock()); |
- consumer_waiter_list_->CancelAllWaiters(); |
+ consumer_awakable_list_->CancelAll(); |
} |
void DataPipe::ConsumerClose() { |
@@ -255,13 +255,13 @@ void DataPipe::ConsumerClose() { |
DCHECK(consumer_open_); |
consumer_open_ = false; |
DCHECK(has_local_consumer_no_lock()); |
- consumer_waiter_list_.reset(); |
+ consumer_awakable_list_.reset(); |
// Not a bug, except possibly in "user" code. |
DVLOG_IF(2, consumer_in_two_phase_read_no_lock()) |
<< "Consumer closed with active two-phase read"; |
consumer_two_phase_max_num_bytes_read_ = 0; |
ConsumerCloseImplNoLock(); |
- AwakeProducerWaitersForStateChangeNoLock( |
+ AwakeProducerAwakablesForStateChangeNoLock( |
ProducerGetHandleSignalsStateImplNoLock()); |
} |
@@ -291,7 +291,7 @@ MojoResult DataPipe::ConsumerReadData(UserPointer<void> elements, |
HandleSignalsState new_producer_state = |
ProducerGetHandleSignalsStateImplNoLock(); |
if (!new_producer_state.equals(old_producer_state)) |
- AwakeProducerWaitersForStateChangeNoLock(new_producer_state); |
+ AwakeProducerAwakablesForStateChangeNoLock(new_producer_state); |
return rv; |
} |
@@ -320,7 +320,7 @@ MojoResult DataPipe::ConsumerDiscardData(UserPointer<uint32_t> num_bytes, |
HandleSignalsState new_producer_state = |
ProducerGetHandleSignalsStateImplNoLock(); |
if (!new_producer_state.equals(old_producer_state)) |
- AwakeProducerWaitersForStateChangeNoLock(new_producer_state); |
+ AwakeProducerAwakablesForStateChangeNoLock(new_producer_state); |
return rv; |
} |
@@ -380,15 +380,15 @@ MojoResult DataPipe::ConsumerEndReadData(uint32_t num_bytes_read) { |
// Two-phase read ended even on failure. |
DCHECK(!consumer_in_two_phase_read_no_lock()); |
// If we're now readable, we *became* readable (since we weren't readable |
- // during the two-phase read), so awake consumer waiters. |
+ // during the two-phase read), so awake consumer awakables. |
HandleSignalsState new_consumer_state = |
ConsumerGetHandleSignalsStateImplNoLock(); |
if (new_consumer_state.satisfies(MOJO_HANDLE_SIGNAL_READABLE)) |
- AwakeConsumerWaitersForStateChangeNoLock(new_consumer_state); |
+ AwakeConsumerAwakablesForStateChangeNoLock(new_consumer_state); |
HandleSignalsState new_producer_state = |
ProducerGetHandleSignalsStateImplNoLock(); |
if (!new_producer_state.equals(old_producer_state)) |
- AwakeProducerWaitersForStateChangeNoLock(new_producer_state); |
+ AwakeProducerAwakablesForStateChangeNoLock(new_producer_state); |
return rv; |
} |
@@ -398,10 +398,10 @@ HandleSignalsState DataPipe::ConsumerGetHandleSignalsState() { |
return ConsumerGetHandleSignalsStateImplNoLock(); |
} |
-MojoResult DataPipe::ConsumerAddWaiter(Waiter* waiter, |
- MojoHandleSignals signals, |
- uint32_t context, |
- HandleSignalsState* signals_state) { |
+MojoResult DataPipe::ConsumerAddAwakable(Awakable* awakable, |
+ MojoHandleSignals signals, |
+ uint32_t context, |
+ HandleSignalsState* signals_state) { |
base::AutoLock locker(lock_); |
DCHECK(has_local_consumer_no_lock()); |
@@ -417,15 +417,15 @@ MojoResult DataPipe::ConsumerAddWaiter(Waiter* waiter, |
return MOJO_RESULT_FAILED_PRECONDITION; |
} |
- consumer_waiter_list_->AddWaiter(waiter, signals, context); |
+ consumer_awakable_list_->Add(awakable, signals, context); |
return MOJO_RESULT_OK; |
} |
-void DataPipe::ConsumerRemoveWaiter(Waiter* waiter, |
- HandleSignalsState* signals_state) { |
+void DataPipe::ConsumerRemoveAwakable(Awakable* awakable, |
+ HandleSignalsState* signals_state) { |
base::AutoLock locker(lock_); |
DCHECK(has_local_consumer_no_lock()); |
- consumer_waiter_list_->RemoveWaiter(waiter); |
+ consumer_awakable_list_->Remove(awakable); |
if (signals_state) |
*signals_state = ConsumerGetHandleSignalsStateImplNoLock(); |
} |
@@ -444,8 +444,10 @@ DataPipe::DataPipe(bool has_local_producer, |
capacity_num_bytes_(validated_options.capacity_num_bytes), |
producer_open_(true), |
consumer_open_(true), |
- producer_waiter_list_(has_local_producer ? new WaiterList() : nullptr), |
- consumer_waiter_list_(has_local_consumer ? new WaiterList() : nullptr), |
+ producer_awakable_list_(has_local_producer ? new AwakableList() |
+ : nullptr), |
+ consumer_awakable_list_(has_local_consumer ? new AwakableList() |
+ : nullptr), |
producer_two_phase_max_num_bytes_written_(0), |
consumer_two_phase_max_num_bytes_read_(0) { |
// Check that the passed in options actually are validated. |
@@ -457,24 +459,24 @@ DataPipe::DataPipe(bool has_local_producer, |
DataPipe::~DataPipe() { |
DCHECK(!producer_open_); |
DCHECK(!consumer_open_); |
- DCHECK(!producer_waiter_list_); |
- DCHECK(!consumer_waiter_list_); |
+ DCHECK(!producer_awakable_list_); |
+ DCHECK(!consumer_awakable_list_); |
} |
-void DataPipe::AwakeProducerWaitersForStateChangeNoLock( |
+void DataPipe::AwakeProducerAwakablesForStateChangeNoLock( |
const HandleSignalsState& new_producer_state) { |
lock_.AssertAcquired(); |
if (!has_local_producer_no_lock()) |
return; |
- producer_waiter_list_->AwakeWaitersForStateChange(new_producer_state); |
+ producer_awakable_list_->AwakeForStateChange(new_producer_state); |
} |
-void DataPipe::AwakeConsumerWaitersForStateChangeNoLock( |
+void DataPipe::AwakeConsumerAwakablesForStateChangeNoLock( |
const HandleSignalsState& new_consumer_state) { |
lock_.AssertAcquired(); |
if (!has_local_consumer_no_lock()) |
return; |
- consumer_waiter_list_->AwakeWaitersForStateChange(new_consumer_state); |
+ consumer_awakable_list_->AwakeForStateChange(new_consumer_state); |
} |
} // namespace system |