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

Unified Diff: mojo/edk/system/data_pipe.cc

Issue 1856113002: EDK: Add implementation of data pipe consumer read threshold stuff. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/data_pipe.h ('k') | mojo/edk/system/data_pipe_consumer_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/data_pipe.cc
diff --git a/mojo/edk/system/data_pipe.cc b/mojo/edk/system/data_pipe.cc
index 61a8793a1f9c1cbce1a6a5d41c6a1d8277172754..9a90c8a549cb6d0cdf6754313a6d3bcb09878bc4 100644
--- a/mojo/edk/system/data_pipe.cc
+++ b/mojo/edk/system/data_pipe.cc
@@ -458,6 +458,29 @@ void DataPipe::ConsumerClose() {
ConsumerCloseNoLock();
}
+MojoResult DataPipe::ConsumerSetOptions(uint32_t read_threshold_num_bytes) {
+ MutexLocker locker(&mutex_);
+ DCHECK(has_local_consumer_no_lock());
+
+ if (read_threshold_num_bytes % element_num_bytes() != 0)
+ return MOJO_RESULT_INVALID_ARGUMENT;
+
+ HandleSignalsState old_consumer_state =
+ impl_->ConsumerGetHandleSignalsState();
+ consumer_read_threshold_num_bytes_ = read_threshold_num_bytes;
+ HandleSignalsState new_consumer_state =
+ impl_->ConsumerGetHandleSignalsState();
+ if (!new_consumer_state.equals(old_consumer_state))
+ AwakeConsumerAwakablesForStateChangeNoLock(new_consumer_state);
+ return MOJO_RESULT_OK;
+}
+
+void DataPipe::ConsumerGetOptions(uint32_t* read_threshold_num_bytes) {
+ MutexLocker locker(&mutex_);
+ DCHECK(has_local_consumer_no_lock());
+ *read_threshold_num_bytes = consumer_read_threshold_num_bytes_;
+}
+
MojoResult DataPipe::ConsumerReadData(UserPointer<void> elements,
UserPointer<uint32_t> num_bytes,
bool all_or_none,
@@ -663,6 +686,7 @@ DataPipe::DataPipe(bool has_local_producer,
capacity_num_bytes_(validated_options.capacity_num_bytes),
producer_open_(true),
consumer_open_(true),
+ consumer_read_threshold_num_bytes_(0),
producer_awakable_list_(has_local_producer ? new AwakableList()
: nullptr),
consumer_awakable_list_(has_local_consumer ? new AwakableList()
« no previous file with comments | « mojo/edk/system/data_pipe.h ('k') | mojo/edk/system/data_pipe_consumer_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698