| 1 | #pragma once |
| 2 | |
| 3 | #ifdef NNSDK |
| 4 | #include <nn/os.h> |
| 5 | #endif |
| 6 | |
| 7 | namespace sead |
| 8 | { |
| 9 | class Heap; |
| 10 | |
| 11 | class MessageQueue |
| 12 | { |
| 13 | public: |
| 14 | #ifdef NNSDK |
| 15 | using Element = s64; |
| 16 | #else |
| 17 | #error "Unknown platform" |
| 18 | using Element = u64; |
| 19 | #endif |
| 20 | |
| 21 | enum class BlockType |
| 22 | { |
| 23 | Blocking = 0, |
| 24 | NonBlocking = 1, |
| 25 | }; |
| 26 | |
| 27 | MessageQueue(); |
| 28 | ~MessageQueue(); |
| 29 | |
| 30 | void allocate(s32 size, Heap* heap); |
| 31 | void free(); |
| 32 | bool push(Element message, BlockType block_type); |
| 33 | Element pop(BlockType block_type); |
| 34 | Element peek(BlockType block_type) const; |
| 35 | bool jam(Element message, BlockType block_type); |
| 36 | |
| 37 | static constexpr Element cNullElement = 0; |
| 38 | |
| 39 | private: |
| 40 | #ifdef NNSDK |
| 41 | nn::os::MessageQueueType mMessageQueueInner; |
| 42 | Element* mBuffer = nullptr; |
| 43 | #else |
| 44 | #error "Unknown platform" |
| 45 | #endif |
| 46 | }; |
| 47 | } // namespace sead |
| 48 | |