summaryrefslogtreecommitdiff
path: root/include/producer.h
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2015-05-13 13:26:12 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-05-26 19:36:21 +0000
commit855646e36bebce29b929178cfb3c73b8f259c8b6 (patch)
treec0fcdc616da4ade170502a0cb842d70d1c44821b /include/producer.h
parenta0ebf0a008670ece41529a2fce01882192331c6e (diff)
downloadchrome-ec-855646e36bebce29b929178cfb3c73b8f259c8b6.tar.gz
Producer/Consumer: Refactor to use Queue policies
Previously the Producer and Consumer interfaces tracked the Consumer and Producer respectively at the other end of the queue that they interacted with. This was done to avoid modifying the queue implementation, but resulted in a rougher interface that required additional initialization steps and prevented alternative configurations; many producers and one consumer for example. This commit uses the new queue policies to track this information. The new direct policy behaves as the old producer and consumers did. Now the producers and consumers are just named references to the queue that they work on and a convenient location for a notification callback when the queue is updated in a way that is relevent to the producer or consumer. All users of Producer and Consumer have been updated including the stream adaptors which are in use by the echo test code and the mcdp28x0 driver. Use of the stream adaptors has also been simplified. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Manual testing of Ryu (P5) and discovery board echo task Change-Id: I704be6378a31b4e20f5063295eff9943e4900409 Reviewed-on: https://chromium-review.googlesource.com/271792 Reviewed-by: Anton Staaf <robotboy@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'include/producer.h')
-rw-r--r--include/producer.h38
1 files changed, 2 insertions, 36 deletions
diff --git a/include/producer.h b/include/producer.h
index d42e148ea6..d120fbc145 100644
--- a/include/producer.h
+++ b/include/producer.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015 The Chromium OS Authors. All rights reserved.
+/* Copyright 2015 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -31,45 +31,11 @@ struct producer_ops {
struct producer {
/*
- * A producer references the consumer at the other end of the queue.
- * This allows the producer to notify the consumer when new units are
- * added to the queue.
- */
- struct consumer const *consumer;
-
- /*
- * A producer also references the queue that it is writing into. This
- * and the consumer reference above could be more flexibly replaced by
- * a queue manager object that could handle multiple producer/consumers
- * or alternate notification mechanisms. But that complexity is not
- * yet warranted.
+ * A producer references the queue that it is writing into.
*/
struct queue const *queue;
struct producer_ops const *ops;
};
-/*
- * Notify the producer by calling its read method directly, as opposed to from
- * a deferred callback or another task.
- */
-void producer_notify_directly(struct producer const *producer, size_t count);
-
-/*
- * Write a single unit to the queue and notify the associated consumer. Return
- * the number of units written.
- */
-size_t producer_write_unit(struct producer const *producer, void const *unit);
-
-/*
- * Write multiple units to the queue, using the provided memcpy like routine
- * and notify the consumer. Return the number of units written.
- */
-size_t producer_write_memcpy(struct producer const *producer,
- void const *units,
- size_t count,
- void *(*memcpy)(void *dest,
- void const *src,
- size_t n));
-
#endif /* INCLUDE_PRODUCER_H */