Bug 1929458 - support setting OS version to use in failure annotations generated...
[gecko.git] / dom / midi / MIDIMessageQueue.h
blobcadfc1b2495ec4db695ce16a629538b6874e59c5
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_MIDIMessageQueue_h
8 #define mozilla_dom_MIDIMessageQueue_h
10 #include "mozilla/Mutex.h"
11 #include "nsTArray.h"
13 // XXX Avoid including this here by moving function implementations to the cpp
14 // file.
15 #include "mozilla/dom/MIDITypes.h"
17 namespace mozilla {
19 class TimeStamp;
21 namespace dom {
23 class MIDIMessage;
25 /**
26 * Since some MIDI Messages can be scheduled to be sent in the future, the
27 * MIDIMessageQueue is responsible for making sure all MIDI messages are
28 * scheduled and sent in order.
30 class MIDIMessageQueue {
31 public:
32 MIDIMessageQueue();
33 ~MIDIMessageQueue() = default;
34 // Adds an array of possibly out-of-order messages to our queue.
35 void Add(nsTArray<MIDIMessage>& aMsg);
36 // Retrieve all pending messages before the time specified.
37 void GetMessagesBefore(TimeStamp aTimestamp,
38 nsTArray<MIDIMessage>& aMsgQueue);
39 // Get all pending messages.
40 void GetMessages(nsTArray<MIDIMessage>& aMsgQueue);
41 // Erase all pending messages.
42 void Clear();
43 // Erase all pending messages that would be sent in the future. Useful for
44 // when ports are closed, as we must send all messages with timestamps in the
45 // past.
46 void ClearAfterNow();
48 private:
49 // Array of messages to be sent.
50 nsTArray<MIDIMessage> mMessageQueue;
51 // Mutex for coordinating cross thread array access.
52 Mutex mMutex MOZ_UNANNOTATED;
55 } // namespace dom
56 } // namespace mozilla
58 #endif // mozilla_dom_MIDIMessageQueue_h