blob: 7ccf0f6b05dae275f7b95f6d0d73cc068186225d [file] [log] [blame]
Devin Moore9a27da52020-07-06 14:01:21 -07001/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <hidl/MQDescriptor.h>
20#include "MessageQueueBase.h"
21
22namespace android {
23namespace hardware {
24
25template <typename T, MQFlavor flavor>
26struct MessageQueue final : public MessageQueueBase<MQDescriptor, T, flavor> {
27 typedef MQDescriptor<T, flavor> Descriptor;
28 MessageQueue(const Descriptor& Desc, bool resetPointers = true)
29 : MessageQueueBase<MQDescriptor, T, flavor>(Desc, resetPointers) {}
30 ~MessageQueue() = default;
31
32 /**
33 * This constructor uses Ashmem shared memory to create an FMQ
34 * that can contain a maximum of 'numElementsInQueue' elements of type T.
35 *
36 * @param numElementsInQueue Capacity of the MessageQueue in terms of T.
37 * @param configureEventFlagWord Boolean that specifies if memory should
38 * also be allocated and mapped for an EventFlag word.
39 */
40 MessageQueue(size_t numElementsInQueue, bool configureEventFlagWord = false)
41 : MessageQueueBase<MQDescriptor, T, flavor>(numElementsInQueue, configureEventFlagWord) {}
42
43 private:
44 MessageQueue(const MessageQueue& other) = delete;
45 MessageQueue& operator=(const MessageQueue& other) = delete;
46 MessageQueue() = delete;
47};
48
49} // namespace hardware
50} // namespace android