michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsThreadPool_h__ michael@0: #define nsThreadPool_h__ michael@0: michael@0: #include "nsIThreadPool.h" michael@0: #include "nsIThread.h" michael@0: #include "nsIRunnable.h" michael@0: #include "nsEventQueue.h" michael@0: #include "nsCOMArray.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsThreadUtils.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: class nsThreadPool MOZ_FINAL : public nsIThreadPool, michael@0: public nsIRunnable michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIEVENTTARGET michael@0: NS_DECL_NSITHREADPOOL michael@0: NS_DECL_NSIRUNNABLE michael@0: michael@0: nsThreadPool(); michael@0: michael@0: private: michael@0: ~nsThreadPool(); michael@0: michael@0: void ShutdownThread(nsIThread *thread); michael@0: nsresult PutEvent(nsIRunnable *event); michael@0: michael@0: nsCOMArray mThreads; michael@0: nsEventQueue mEvents; michael@0: uint32_t mThreadLimit; michael@0: uint32_t mIdleThreadLimit; michael@0: uint32_t mIdleThreadTimeout; michael@0: uint32_t mIdleCount; michael@0: uint32_t mStackSize; michael@0: nsCOMPtr mListener; michael@0: bool mShutdown; michael@0: nsCString mName; michael@0: nsThreadPoolNaming mThreadNaming; michael@0: }; michael@0: michael@0: #define NS_THREADPOOL_CID \ michael@0: { /* 547ec2a8-315e-4ec4-888e-6e4264fe90eb */ \ michael@0: 0x547ec2a8, \ michael@0: 0x315e, \ michael@0: 0x4ec4, \ michael@0: {0x88, 0x8e, 0x6e, 0x42, 0x64, 0xfe, 0x90, 0xeb} \ michael@0: } michael@0: michael@0: #endif // nsThreadPool_h__