mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
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>
44 lines
1.3 KiB
C
44 lines
1.3 KiB
C
/* 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.
|
|
*
|
|
* Queue policies.
|
|
*/
|
|
#ifndef INCLUDE_QUEUE_POLICIES_H
|
|
#define INCLUDE_QUEUE_POLICIES_H
|
|
|
|
#include "queue.h"
|
|
#include "consumer.h"
|
|
#include "producer.h"
|
|
|
|
/*
|
|
* The direct notification policy manages a 1-to-1 producer consumer model.
|
|
* When new units are added to the queue the consumer is notified directly, in
|
|
* whatever context (interrupt, deferred, task...) that the queue addition
|
|
* happened. Similarly, queue removals directly notify the producer.
|
|
*/
|
|
struct queue_policy_direct {
|
|
struct queue_policy policy;
|
|
|
|
struct producer const *producer;
|
|
struct consumer const *consumer;
|
|
};
|
|
|
|
void queue_add_direct(struct queue_policy const *policy, size_t count);
|
|
void queue_remove_direct(struct queue_policy const *policy, size_t count);
|
|
|
|
#define QUEUE_POLICY_DIRECT(PRODUCER, CONSUMER) \
|
|
((struct queue_policy_direct const) { \
|
|
.policy = { \
|
|
.add = queue_add_direct, \
|
|
.remove = queue_remove_direct, \
|
|
}, \
|
|
.producer = &PRODUCER, \
|
|
.consumer = &CONSUMER, \
|
|
})
|
|
|
|
#define QUEUE_DIRECT(SIZE, TYPE, PRODUCER, CONSUMER) \
|
|
QUEUE(SIZE, TYPE, QUEUE_POLICY_DIRECT(PRODUCER, CONSUMER).policy)
|
|
|
|
#endif /* INCLUDE_QUEUE_POLICIES_H */
|