// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
// An incoming message queue for a port. MessageQueue keeps track of the highest // known sequence number and can indicate whether the next sequential message is // available. Thus the queue enforces message ordering for the consumer without // enforcing it for the producer (see AcceptMessage() below.) class MessageQueue { public: explicit MessageQueue(); explicit MessageQueue(uint64_t next_sequence_num);
~MessageQueue();
// Gives ownership of the message. If |filter| is non-null, the next message // will only be retrieved if the filter successfully matches it. void GetNextMessage(mozilla::UniquePtr<UserMessageEvent>* message,
MessageFilter* filter);
// Mark the message from |GetNextMessage| as processed. void MessageProcessed();
// Takes ownership of the message. Note: Messages are ordered, so while we // have added a message to the queue, we may still be waiting on a message // ahead of this one before we can let any of the messages be returned by // GetNextMessage. // // Furthermore, once has_next_message is set to true, it will remain false // until GetNextMessage is called enough times to return a null message. // In other words, has_next_message acts like an edge trigger. // void AcceptMessage(mozilla::UniquePtr<UserMessageEvent> message, bool* has_next_message);
// Takes all messages from this queue. Used to safely destroy queued messages // without holding any Port lock. void TakeAllMessages(
std::vector<mozilla::UniquePtr<UserMessageEvent>>* messages);
// The number of messages queued here, regardless of whether the next expected // message has arrived yet.
size_t queued_message_count() const { return heap_.size(); }
// The aggregate memory size in bytes of all messages queued here, regardless // of whether the next expected message has arrived yet.
size_t queued_num_bytes() const { return total_queued_bytes_; }
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.