tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

VRThread.h (1190B)


      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 #ifndef GFX_VR_THREAD_H
      8 #define GFX_VR_THREAD_H
      9 
     10 #include "nsISupportsImpl.h"
     11 #include "base/thread.h"  // for Thread
     12 
     13 namespace mozilla {
     14 namespace gfx {
     15 
     16 class VRThread final {
     17  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRThread)
     18 
     19 public:
     20  explicit VRThread(const nsCString& aName);
     21 
     22  void Start();
     23  void Shutdown();
     24  void SetLifeTime(uint32_t aLifeTime);
     25  uint32_t GetLifeTime();
     26  void CheckLife(TimeStamp aCheckTimestamp);
     27  void PostTask(already_AddRefed<Runnable> aTask);
     28  void PostDelayedTask(already_AddRefed<Runnable> aTask, uint32_t aTime);
     29  const nsCOMPtr<nsIThread> GetThread() const;
     30  bool IsActive();
     31 
     32 protected:
     33  ~VRThread();
     34 
     35 private:
     36  nsCOMPtr<nsIThread> mThread;
     37  TimeStamp mLastActiveTime;
     38  nsCString mName;
     39  uint32_t mLifeTime;
     40  Atomic<bool> mStarted;
     41 };
     42 
     43 }  // namespace gfx
     44 }  // namespace mozilla
     45 
     46 #endif  // GFX_VR_THREAD_H