xpcom/threads/nsThreadPool.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     7 #ifndef nsThreadPool_h__
     8 #define nsThreadPool_h__
    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"
    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
    28   nsThreadPool();
    30 private:
    31   ~nsThreadPool();
    33   void ShutdownThread(nsIThread *thread);
    34   nsresult PutEvent(nsIRunnable *event);
    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 };
    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 }
    57 #endif  // nsThreadPool_h__

mercurial