Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / security / manager / ssl / PSMRunnable.h
blobfaafb14c609402d21dc005db8156a587304e65d6
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef PSMRunnable_h
6 #define PSMRunnable_h
8 #include "mozilla/Monitor.h"
9 #include "nsThreadUtils.h"
10 #include "nsIObserver.h"
11 #include "nsProxyRelease.h"
13 namespace mozilla {
14 namespace psm {
16 // Wait for the event to run on the target thread without spinning the event
17 // loop on the calling thread. (Dispatching events to a thread using
18 // NS_DispatchAndSpinEventLoopUntilComplete would cause the event loop on the
19 // calling thread to spin.)
20 class SyncRunnableBase : public Runnable {
21 public:
22 NS_DECL_NSIRUNNABLE
23 nsresult DispatchToMainThreadAndWait();
25 protected:
26 SyncRunnableBase();
27 virtual void RunOnTargetThread() = 0;
29 private:
30 mozilla::Monitor monitor MOZ_UNANNOTATED;
33 class NotifyObserverRunnable : public Runnable {
34 public:
35 NotifyObserverRunnable(nsIObserver* observer, const char* topicStringLiteral)
36 : Runnable("psm::NotifyObserverRunnable"),
37 mObserver(new nsMainThreadPtrHolder<nsIObserver>(
38 "psm::NotifyObserverRunnable::mObserver", observer)),
39 mTopic(topicStringLiteral) {}
40 NS_DECL_NSIRUNNABLE
41 private:
42 nsMainThreadPtrHandle<nsIObserver> mObserver;
43 const char* const mTopic;
46 } // namespace psm
47 } // namespace mozilla
49 #endif