|
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 nsThreadPool_h__ |
|
8 #define nsThreadPool_h__ |
|
9 |
|
10 #include "nsIThreadPool.h" |
|
11 #include "nsIThread.h" |
|
12 #include "nsIRunnable.h" |
|
13 #include "nsEventQueue.h" |
|
14 #include "nsCOMArray.h" |
|
15 #include "nsCOMPtr.h" |
|
16 #include "nsThreadUtils.h" |
|
17 #include "mozilla/Attributes.h" |
|
18 |
|
19 class nsThreadPool MOZ_FINAL : public nsIThreadPool, |
|
20 public nsIRunnable |
|
21 { |
|
22 public: |
|
23 NS_DECL_THREADSAFE_ISUPPORTS |
|
24 NS_DECL_NSIEVENTTARGET |
|
25 NS_DECL_NSITHREADPOOL |
|
26 NS_DECL_NSIRUNNABLE |
|
27 |
|
28 nsThreadPool(); |
|
29 |
|
30 private: |
|
31 ~nsThreadPool(); |
|
32 |
|
33 void ShutdownThread(nsIThread *thread); |
|
34 nsresult PutEvent(nsIRunnable *event); |
|
35 |
|
36 nsCOMArray<nsIThread> mThreads; |
|
37 nsEventQueue mEvents; |
|
38 uint32_t mThreadLimit; |
|
39 uint32_t mIdleThreadLimit; |
|
40 uint32_t mIdleThreadTimeout; |
|
41 uint32_t mIdleCount; |
|
42 uint32_t mStackSize; |
|
43 nsCOMPtr<nsIThreadPoolListener> mListener; |
|
44 bool mShutdown; |
|
45 nsCString mName; |
|
46 nsThreadPoolNaming mThreadNaming; |
|
47 }; |
|
48 |
|
49 #define NS_THREADPOOL_CID \ |
|
50 { /* 547ec2a8-315e-4ec4-888e-6e4264fe90eb */ \ |
|
51 0x547ec2a8, \ |
|
52 0x315e, \ |
|
53 0x4ec4, \ |
|
54 {0x88, 0x8e, 0x6e, 0x42, 0x64, 0xfe, 0x90, 0xeb} \ |
|
55 } |
|
56 |
|
57 #endif // nsThreadPool_h__ |