Bug 1890689 accumulate input in LargerReceiverBlockSizeThanDesiredBuffering GTest...
[gecko.git] / gfx / ipc / VsyncIOThreadHolder.cpp
blobb5b04dcf185875a35e7e2a1d209773e179d1efde
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/. */
7 #include "VsyncIOThreadHolder.h"
9 #include "mozilla/SchedulerGroup.h"
11 namespace mozilla {
12 namespace gfx {
14 VsyncIOThreadHolder::VsyncIOThreadHolder() {
15 MOZ_COUNT_CTOR(VsyncIOThreadHolder);
18 VsyncIOThreadHolder::~VsyncIOThreadHolder() {
19 MOZ_COUNT_DTOR(VsyncIOThreadHolder);
21 if (!mThread) {
22 return;
25 if (NS_IsMainThread()) {
26 mThread->AsyncShutdown();
27 } else {
28 SchedulerGroup::Dispatch(NewRunnableMethod(
29 "nsIThread::AsyncShutdown", mThread, &nsIThread::AsyncShutdown));
33 bool VsyncIOThreadHolder::Start() {
34 /* "VsyncIOThread" is used as the thread we send/recv IPC messages on. We
35 * don't use the "WindowsVsyncThread" directly because it isn't servicing an
36 * nsThread event loop which is needed for IPC to return results/notify us
37 * about shutdown etc.
39 * It would be better if we could notify the IPC IO thread directly to avoid
40 * the extra ping-ponging but that doesn't seem possible. */
41 nsresult rv = NS_NewNamedThread("VsyncIOThread", getter_AddRefs(mThread));
42 return NS_SUCCEEDED(rv);
45 RefPtr<nsIThread> VsyncIOThreadHolder::GetThread() const { return mThread; }
47 } // namespace gfx
48 } // namespace mozilla