Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/xpcom/threads/EventQueue.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
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/. */
6
7
#include "mozilla/EventQueue.h"
8
#include "nsIRunnable.h"
9
10
using namespace mozilla;
11
12
EventQueue::EventQueue(EventPriority aPriority)
13
12
{
14
12
}
15
16
void
17
EventQueue::PutEvent(already_AddRefed<nsIRunnable>&& aEvent,
18
                     EventPriority aPriority,
19
                     const MutexAutoLock& aProofOfLock)
20
194
{
21
194
  nsCOMPtr<nsIRunnable> event(aEvent);
22
194
  mQueue.Push(std::move(event));
23
194
}
24
25
already_AddRefed<nsIRunnable>
26
EventQueue::GetEvent(EventPriority* aPriority,
27
                     const MutexAutoLock& aProofOfLock)
28
63
{
29
63
  if (mQueue.IsEmpty()) {
30
32
    return nullptr;
31
32
  }
32
31
33
31
  if (aPriority) {
34
18
    *aPriority = EventPriority::Normal;
35
18
  }
36
31
37
31
  nsCOMPtr<nsIRunnable> result = mQueue.Pop();
38
31
  return result.forget();
39
31
}
40
41
bool
42
EventQueue::IsEmpty(const MutexAutoLock& aProofOfLock)
43
19
{
44
19
  return mQueue.IsEmpty();
45
19
}
46
47
bool
48
EventQueue::HasReadyEvent(const MutexAutoLock& aProofOfLock)
49
19
{
50
19
  return !IsEmpty(aProofOfLock);
51
19
}
52
53
already_AddRefed<nsIRunnable>
54
EventQueue::PeekEvent(const MutexAutoLock& aProofOfLock)
55
0
{
56
0
  if (mQueue.IsEmpty()) {
57
0
    return nullptr;
58
0
  }
59
0
60
0
  nsCOMPtr<nsIRunnable> result = mQueue.FirstElement();
61
0
  return result.forget();
62
0
}
63
64
size_t
65
EventQueue::Count(const MutexAutoLock& aProofOfLock) const
66
0
{
67
0
  return mQueue.Count();
68
0
}