gecko-dev/gfx/vr/VRThread.h
Daosheng Mu 1726d42a0c Bug 1406327 - Part 1: Shutdown VR listener thread when no VR content in seconds; r=dvander,kip
MozReview-Commit-ID: AnYJT8WBkI7

--HG--
extra : rebase_source : 5d336ca6f5fb9fbcfd993e5e699d363a22bbe304
2017-10-26 16:51:14 +08:00

53 lines
1.3 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();
static TimeStamp GetStartTime();
private:
~VRListenerThreadHolder();
static base::Thread* CreateThread();
static void DestroyThread(base::Thread* aThread);
base::Thread* const mThread;
};
base::Thread* VRListenerThread();
} // namespace gfx
} // namespace mozilla
#endif // GFX_VR_THREAD_H