xpcom/threads/nsThreadPool.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/threads/nsThreadPool.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef nsThreadPool_h__
    1.11 +#define nsThreadPool_h__
    1.12 +
    1.13 +#include "nsIThreadPool.h"
    1.14 +#include "nsIThread.h"
    1.15 +#include "nsIRunnable.h"
    1.16 +#include "nsEventQueue.h"
    1.17 +#include "nsCOMArray.h"
    1.18 +#include "nsCOMPtr.h"
    1.19 +#include "nsThreadUtils.h"
    1.20 +#include "mozilla/Attributes.h"
    1.21 +
    1.22 +class nsThreadPool MOZ_FINAL : public nsIThreadPool,
    1.23 +                               public nsIRunnable
    1.24 +{
    1.25 +public:
    1.26 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.27 +  NS_DECL_NSIEVENTTARGET
    1.28 +  NS_DECL_NSITHREADPOOL
    1.29 +  NS_DECL_NSIRUNNABLE
    1.30 +
    1.31 +  nsThreadPool();
    1.32 +
    1.33 +private:
    1.34 +  ~nsThreadPool();
    1.35 +
    1.36 +  void ShutdownThread(nsIThread *thread);
    1.37 +  nsresult PutEvent(nsIRunnable *event);
    1.38 +
    1.39 +  nsCOMArray<nsIThread> mThreads;
    1.40 +  nsEventQueue          mEvents;
    1.41 +  uint32_t              mThreadLimit;
    1.42 +  uint32_t              mIdleThreadLimit;
    1.43 +  uint32_t              mIdleThreadTimeout;
    1.44 +  uint32_t              mIdleCount;
    1.45 +  uint32_t              mStackSize;
    1.46 +  nsCOMPtr<nsIThreadPoolListener> mListener;
    1.47 +  bool                  mShutdown;
    1.48 +  nsCString             mName;
    1.49 +  nsThreadPoolNaming    mThreadNaming;
    1.50 +};
    1.51 +
    1.52 +#define NS_THREADPOOL_CID                          \
    1.53 +{ /* 547ec2a8-315e-4ec4-888e-6e4264fe90eb */       \
    1.54 +  0x547ec2a8,                                      \
    1.55 +  0x315e,                                          \
    1.56 +  0x4ec4,                                          \
    1.57 +  {0x88, 0x8e, 0x6e, 0x42, 0x64, 0xfe, 0x90, 0xeb} \
    1.58 +}
    1.59 +
    1.60 +#endif  // nsThreadPool_h__

mercurial