gecko-dev/gfx/vr/VRThread.h
Daosheng Mu 08ffc52b07 Bug 1415762 - Cancel VRListener task when CompositorVsyncScheduler is going to destroy; r=dvander
MozReview-Commit-ID: F25LE5Ru9gz

--HG--
extra : rebase_source : c870e2a987fd4a113d67e6672eb1e53a030fad65
2017-11-09 11:41:15 +08:00

52 lines
1.2 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef GFX_VR_THREAD_H
#define GFX_VR_THREAD_H
#include "ThreadSafeRefcountingWithMainThreadDestruction.h"
#include "base/thread.h" // for Thread
namespace mozilla {
namespace gfx {
class VRListenerThreadHolder final
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(VRListenerThreadHolder)
public:
VRListenerThreadHolder();
base::Thread* GetThread() const {
return mThread;
}
static VRListenerThreadHolder* GetSingleton();
static bool IsActive() {
return GetSingleton() && Loop();
}
static void Start();
static void Shutdown();
static MessageLoop* Loop();
static bool IsInVRListenerThread();
private:
~VRListenerThreadHolder();
base::Thread* const mThread;
static base::Thread* CreateThread();
static void DestroyThread(base::Thread* aThread);
};
base::Thread* VRListenerThread();
} // namespace gfx
} // namespace mozilla
#endif // GFX_VR_THREAD_H