tor-browser

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

ExecuteIfOnMainThreadEventTarget.h (1058B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
      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 ExecuteIfOnMainThreadEventTarget_h__
      8 #define ExecuteIfOnMainThreadEventTarget_h__
      9 
     10 #include "nsISerialEventTarget.h"
     11 
     12 namespace mozilla {
     13 namespace net {
     14 
     15 /*
     16  An event target that will execute the runnable immediately if on the main
     17  thread, avoiding a dispatch to the end of queue. Otherwise the runnable will
     18  be dispatched to the main thread.
     19 */
     20 class ExecuteIfOnMainThreadEventTarget final : public nsISerialEventTarget {
     21 public:
     22  ExecuteIfOnMainThreadEventTarget() {}
     23 
     24  NS_DECL_THREADSAFE_ISUPPORTS
     25  NS_DECL_NSIEVENTTARGET
     26  NS_DECL_NSISERIALEVENTTARGET
     27 
     28  static nsISerialEventTarget* Get();
     29 
     30 private:
     31  ~ExecuteIfOnMainThreadEventTarget() = default;
     32 };
     33 
     34 }  // namespace net
     35 }  // namespace mozilla
     36 
     37 #endif