Devin Moore | 9a27da5 | 2020-07-06 14:01:21 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 22 | namespace android { |
| 23 | namespace hardware { |
| 24 | |
| 25 | template <typename T, MQFlavor flavor> |
| 26 | struct 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 |