security/manager/ssl/src/nsPSMBackgroundThread.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef _NSPSMBACKGROUNDTHREAD_H_
michael@0 6 #define _NSPSMBACKGROUNDTHREAD_H_
michael@0 7
michael@0 8 #include "nspr.h"
michael@0 9 #include "nscore.h"
michael@0 10 #include "mozilla/CondVar.h"
michael@0 11 #include "mozilla/Mutex.h"
michael@0 12 #include "nsNSSComponent.h"
michael@0 13
michael@0 14 class nsPSMBackgroundThread
michael@0 15 {
michael@0 16 protected:
michael@0 17 static void nsThreadRunner(void *arg);
michael@0 18 virtual void Run(void) = 0;
michael@0 19
michael@0 20 // used to join the thread
michael@0 21 PRThread *mThreadHandle;
michael@0 22
michael@0 23 // Shared mutex used for condition variables,
michael@0 24 // and to protect access to mExitState.
michael@0 25 // Derived classes may use it to protect additional
michael@0 26 // resources.
michael@0 27 mozilla::Mutex mMutex;
michael@0 28
michael@0 29 // Used to signal the thread's Run loop when a job is added
michael@0 30 // and/or exit is requested.
michael@0 31 mozilla::CondVar mCond;
michael@0 32
michael@0 33 bool exitRequested(::mozilla::MutexAutoLock const & proofOfLock) const;
michael@0 34 bool exitRequestedNoLock() const { return mExitState != ePSMThreadRunning; }
michael@0 35 nsresult postStoppedEventToMainThread(::mozilla::MutexAutoLock const & proofOfLock);
michael@0 36
michael@0 37 private:
michael@0 38 enum {
michael@0 39 ePSMThreadRunning = 0,
michael@0 40 ePSMThreadStopRequested = 1,
michael@0 41 ePSMThreadStopped = 2
michael@0 42 } mExitState;
michael@0 43
michael@0 44 // The thread's name.
michael@0 45 nsCString mName;
michael@0 46
michael@0 47 public:
michael@0 48 nsPSMBackgroundThread();
michael@0 49 virtual ~nsPSMBackgroundThread();
michael@0 50
michael@0 51 nsresult startThread(const nsCSubstring & name);
michael@0 52 void requestExit();
michael@0 53 };
michael@0 54
michael@0 55
michael@0 56 #endif

mercurial