Bug 1700051: part 49) Add some documentation to `Selection::GetRangesForInterval...
[gecko.git] / xpcom / threads / nsThreadPool.h
blob7bdafde57c660af92875d1fdbeaf0e7fb39faa4e
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/. */
7 #ifndef nsThreadPool_h__
8 #define nsThreadPool_h__
10 #include "nsIThreadPool.h"
11 #include "nsIRunnable.h"
12 #include "nsCOMArray.h"
13 #include "nsCOMPtr.h"
14 #include "nsThreadUtils.h"
15 #include "mozilla/Atomics.h"
16 #include "mozilla/AlreadyAddRefed.h"
17 #include "mozilla/CondVar.h"
18 #include "mozilla/EventQueue.h"
19 #include "mozilla/Mutex.h"
21 class nsIThread;
23 class nsThreadPool final : public mozilla::Runnable, public nsIThreadPool {
24 public:
25 NS_DECL_ISUPPORTS_INHERITED
26 NS_DECL_NSIEVENTTARGET_FULL
27 NS_DECL_NSITHREADPOOL
28 NS_DECL_NSIRUNNABLE
30 nsThreadPool();
32 private:
33 ~nsThreadPool();
35 void ShutdownThread(nsIThread* aThread);
36 nsresult PutEvent(nsIRunnable* aEvent);
37 nsresult PutEvent(already_AddRefed<nsIRunnable> aEvent, uint32_t aFlags);
39 nsCOMArray<nsIThread> mThreads;
40 mozilla::Mutex mMutex;
41 mozilla::CondVar mEventsAvailable;
42 mozilla::EventQueue mEvents;
43 uint32_t mThreadLimit;
44 uint32_t mIdleThreadLimit;
45 uint32_t mIdleThreadTimeout;
46 uint32_t mIdleCount;
47 uint32_t mStackSize;
48 nsCOMPtr<nsIThreadPoolListener> mListener;
49 bool mShutdown;
50 bool mRegressiveMaxIdleTime;
51 mozilla::Atomic<bool, mozilla::Relaxed> mIsAPoolThreadFree;
52 nsCString mName;
53 nsThreadPoolNaming mThreadNaming;
56 #define NS_THREADPOOL_CID \
57 { /* 547ec2a8-315e-4ec4-888e-6e4264fe90eb */ \
58 0x547ec2a8, 0x315e, 0x4ec4, { \
59 0x88, 0x8e, 0x6e, 0x42, 0x64, 0xfe, 0x90, 0xeb \
60 } \
63 #endif // nsThreadPool_h__