coreboot-libre-fam15h-rdimm/3rdparty/chromeec/common/queue_policies.c

43 lines
1.0 KiB
C
Raw Normal View History

2024-03-04 11:14:53 +01:00
/* 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.
*/
#include "queue_policies.h"
#include "util.h"
#include <stddef.h>
void queue_add_direct(struct queue_policy const *policy, size_t count)
{
struct queue_policy_direct const *direct =
DOWNCAST(policy, struct queue_policy_direct, policy);
if (count && direct->consumer->ops->written)
direct->consumer->ops->written(direct->consumer, count);
}
void queue_remove_direct(struct queue_policy const *policy, size_t count)
{
struct queue_policy_direct const *direct =
DOWNCAST(policy, struct queue_policy_direct, policy);
if (count && direct->producer->ops->read)
direct->producer->ops->read(direct->producer, count);
}
struct producer const null_producer = {
.queue = NULL,
.ops = &((struct producer_ops const) {
.read = NULL,
}),
};
struct consumer const null_consumer = {
.queue = NULL,
.ops = &((struct consumer_ops const) {
.written = NULL,
}),
};