C
<platform/messagequeue.h> - Queue abstraction
为特定平台的队列提供抽象层。更多内容...
| Header: | #include <platform/messagequeue.h> |
属于Qt Quick Ultralite平台API的一部分。
类型
(since Qt Quick Ultralite (Platform) 1.9) enum class | MessageQueueStatus { Success, MessageDiscarded, MessageOverwritten, EmptyQueue, Timeout, …, OtherError } |
函数
(since Qt Quick Ultralite (Platform) 1.9) void | deleteQueue(Qul::Platform::MessageQueueInterface *queue) |
(since Qt Quick Ultralite (Platform) 1.9) std::size_t | maximumQueueMessageSize() |
(since Qt Quick Ultralite (Platform) 1.9) Qul::Platform::MessageQueueInterface * | requestQueue(std::size_t queueCapacity, std::size_t messageSize) |
详细说明
此头文件包含所有由EventQueues 使用的队列接口抽象,这些接口由Qt Quick Ultralite核心库处理。
类
一个用于与队列实现进行交互的便捷类 | |
为Qt Quick Ultralite 提供平台特定队列的接口类 |
类型文档
[since Qt Quick Ultralite (Platform) 1.9] enum class MessageQueueStatus
MessageQueueInterface 函数返回的状态码。
| 常量 | 值 | 描述 |
|---|---|---|
MessageQueueStatus::Success | 0 | 函数执行成功。 |
MessageQueueStatus::MessageDiscarded | 1 | 消息已被丢弃。仅当 MessageQueueInterface::enqueueOrDiscard() 和 MessageQueueInterface::enqueueOrDiscardFromInterrupt() 函数丢弃给定消息时,才应返回此值。 |
MessageQueueStatus::MessageOverwritten | 2 | 队列中的一个消息被给定的消息覆盖。此值仅应由 MessageQueueInterface::enqueueOrOverwrite() 和 MessageQueueInterface::enqueueOrOverwriteFromInterrupt() 函数返回。 |
MessageQueueStatus::EmptyQueue | 3 | MessageQueueInterface::receive() 或 MessageQueueInterface::receiveFromInterrupt() 无法从队列中获取消息,因为队列为空。 |
MessageQueueStatus::Timeout | 4 | 在超时ms 内无法从队列中获取消息。 |
MessageQueueStatus::DiscardNotSupported | 5 | 队列实现不支持丢弃操作。 |
MessageQueueStatus::OverwriteNotSupported | 6 | 队列实现不支持覆盖。 |
MessageQueueStatus::OtherError | 7 | 没有任何状态码与该函数的状态相符。EventQueue 将其视为错误。 |
该枚举在Qt Quick Ultralite (Platform) 1.9 中引入。
函数文档
[since Qt Quick Ultralite (Platform) 1.9] void deleteQueue(Qul::Platform::MessageQueueInterface *queue)
删除queue 。
MessageQueue 会调用此函数,在不再需要某个队列时将其删除。
以下是该函数的一个实现示例:
void deleteQueue(MessageQueueInterface *queue) { MyMessageQueue *mq = static_cast<MyMessageQueue *>(queue); mq->~MyMessageQueue(); qul_free(mq); }
该函数首次出现在Qt Quick Ultralite (Platform) 1.9 版本中。
另请参阅 requestQueue()、maximumQueueMessageSize()、Qul::Platform::MessageQueue 以及Qul::Platform::MessageQueueInterface 。
[since Qt Quick Ultralite (Platform) 1.9] std::size_t maximumQueueMessageSize()
返回队列可容纳的消息的最大大小。如果队列的消息最大大小未知或为任意值,则必须返回SIZE_MAX 。
该函数首次出现在Qt Quick Ultralite (Platform) 1.9 中。
另请参阅 requestQueue()、Qul::Platform::MessageQueue 以及Qul::Platform::MessageQueueInterface 。
[since Qt Quick Ultralite (Platform) 1.9] Qul::Platform::MessageQueueInterface *requestQueue(std::size_t queueCapacity, std::size_t messageSize)
返回一个MessageQueueInterface 实现的实例,其容量为queueCapacity 。该队列必须接受满足messageSize 要求的消息。如果该实现无法满足queueCapacity 或messageSize 的要求,则该函数必须返回一个空指针。
MessageQueue 函数会使用此函数来获取适合其使用的队列。
以下是该函数的一个实现示例:
MessageQueueInterface *requestQueue(size_t queueCapacity, size_t messageSize) { void *queue = qul_malloc(sizeof(MyMessageQueue)); if (queue == NULL) { return NULL; } MessageQueueInterface *interface = new (queue) MyMessageQueue(queueCapacity, messageSize); return interface; }
该函数首次引入于Qt Quick Ultralite (Platform) 1.9 版本。
另请参阅 deleteQueue()、maximumQueueMessageSize()、Qul::Platform::MessageQueue 以及Qul::Platform::MessageQueueInterface 。
在某些 Qt 许可证下提供。
了解更多信息。