mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
5a3b3d60eb
- Bug 1173260 - stub out tests that fail when 'cursive' is looked up via fontconfig. r=m_kato (0bb3f03cb8)
- bug 1215657 - make AccessibleWrap::get_accDefaultAction work with proxied accessibles r=davidb (5732eb38eb)
- Bug 1210549 - Allow IServiceProvider::QueryService to work for proxied accessibles r=tbsaunde (7dcd9c2271)
- bug 1215657 - make AccessibleWrap::accSelect work with proxies r=davidb (d52e3d4873)
- Bug 1225682 - Don't use nsAuto{,C}String as class member variables in rdf/. r=Pike (f681938445)
- Bug 1232454 - use UniquePtr<T[]> instead of nsAutoArrayPtr<T> in security/apps/; r=keeler (e416936ed6)
- Bug 1235796 - Allow allocating YCbCr textures with Cb/Cr planes bigger than the Y plane. r=jrmuizel (8f1dbe137c)
- Bug 1241816 - In CreateSourceSurfaceFromMacIOSurface, unlock the IOSurface even in failure cases. r=mattwoodrow (218e6da6c1)
- Bug 1240190 - Add D3D9 texture upload profiler labels. r=jrmuizel (1e55b77bdf)
- Bug 1213429 - Recycle e10s D3D9 textures and add partial upload support. r=Bas (97aeeefdd2)
- Bug 1213429 - Check the result of LockRect. r=Bas (1c3c981d80)
- Bug 1213429 - GCC compilation fixup. (5449005c99)
- Lazily initialize D3D11 mix-blend shaders. (bug 1246388, r=mattwoodrow) (6fd3226030)
- Bug 1237375: Add some more extensive debugging information. r=milan (aed95e4774)
- Bug 1239861. Part 2 Properly resize DXGI swap chain buffer size. r=bas (e9bf410de4)
- Bug 1247775 - Part 1: Remove D3D10/D2D 1.0 texture integration from layers. r=dvander (74d7e93792)
- Bug 1247775 - Part 2: Remove Direct2D 1.0 code from Thebes. r=dvander (f0a1f53917)
- Bug 1247775 - Part 3: Remove Moz2D code to support Direct2D 1.0. r=dvander (10d27128eb)
- Bug 1221656 - Copy mp4parse.h in update-rust.sh. r=kinetik (96ebce3eb8)
- Bug 868333 - Match more MP4 family file types in media sniffer. r=rillian (cd29bd2a74)
- Bug 1211802 - Recognize 'avc?' as mp4 video. r=jya (b68726705b)
- Bug 1244523: [mp4] P2. Have sniffer recognise ftyp qt subtype. r=cpearce (1770f0862b)
- Bug 1087488: Remove some SPROP macro usages in Omnijar.cpp, to avoid triggering -Wtautological-compare clang warning. r=glandium (697dfa9895)
- Bug 1228437 - Add BHR stats from e10s child process. B2G fix by Ting-Yu Chou. r=nchen (213fbb9f37)
- Bug 1198196 - rework EVENTLOOP_UI_LAG_EXP_MS to record all lag. r=vladan (2807460ce0)
- Bug 1240484 - fixed control flow patch issue by adding brackets. r=mccr8 (d2aac14ee1)
- Bug 1242119 - Remove early exit in WinXP debug content processes. r=froydnj (2c2626a1ea)
- Bug 1245513 - Use _exit(0) to exit in B2G debug content processes. r=froydnj (c37efd34d9)
- some crash and profiler stuff (87547f6d8f)
- bug 1234417 - fix a leak in CreateECPublicKey r=rbarnes (99848f0fae)
- Bug 1204784: Handle cases in nsThreadPool where Gecko doesn't own the thread that we're running on. r=froydnj (3f523fc544)
- Bug 1204784: Do not shut the main thread down before all outstanding asynchronous thread shutdowns complete. r=froydnj (6abfb2562f)
- Bug 1234126 - Add Chaos Mode support for setting thread affinity on OS X and Windows. r=froydnj (8811430596)
- Bug 1245586 - add debugging aids for thread shutdown; r=khuey (28b7ae88c3)
- Bug 1191936 - Implement SPKI/PKCS#8/JWK import/export for RSA-PSS r=rbarnes (212ab7fec5)
- Bug 1241757 - Permit export of JWK with empty key_ops field, r=rbarnes (b19f177a13)
- Bug 1205168 - Part 0: Remove copy-ctor from strong type. r=jgilbert (a6070322a1)
- Bug 1205168 - Part 1 - Sort all the WebGLTexelFormats. r=jgilbert (857cd58641)
- Bug 1205168 - Part 2: Texel Conversion - RG8 format. r=jgilbert (6c241194ed)
- Bug 1205168 - Part 3: Texel Conversion - RG16F format. r=jgilbert (7573635218)
- Bug 1205168 - Part 4: Texel Conversion - RG32F format. r=jgilbert (f54343317e)
- Bug 1205168 - Part 5: Texel Conversion - RGB11F11F10F format. r=jgilbert (500514e025)
- Bug 1205168 - Part 6: Fix TexImage2D and TexSubImage2D with texture conversion. r=jgilbert (b5e2e75276)
- Bug 1205168 - Part 7: Remove unneeded functions. r=jgilbert (9bd24cd813)
- Bug 1234744 - Fix build errors in ImageBitmap.h. r=roc (b4b67e5905)
- missing telemetry bits (28161fd3f9)
- Bug 1237193 - Fix WebGL getActiveUniforms return type. r=jgilbert, r=smaug (f9a37a360e)
- Bug 1233353 - Initialize rb correctly if rb bind to READ_FRAMEBUFFER. r=jgilbert (bbc77437a4)
- Bug 1237637 - Disallow negative levels for framebuffer attachments. -r=jrmuizel (fa65b6ad24)
- Bug 1236395 - [WebGL2] pass getFramebufferAttachmentParameter in gl-object-get-calls.html, r=jgilbert (6f9fde1cd2)
- Bug 1236784 - [WebGL2] pass getRenderbufferParameter in gl-object-get-calls.html, r=jgilbert (e4f20f54ad)
- Bug 1238865 - Part 1: Validate attachments before clearBuffer. r=jgilbert (a6e6e05a0c)
- Bug 1229210. Handle the new formats required by WebGL2 in ReadPixels. r=jgilbert (66e305f97d)
- Bug 1238865 - Part 2: Add more format/type checks for WebGL2. r=jgilbert (af629782b3)
- Bug 1238865 - Part 3: Prevent IMPLEMENTATION_COLOR_READ_FORMAT return SRGB_ALPHA. r=jgilbert (81da93d791)
- Bug 1240673 - Fix WebGL2 framebuffer parameter problem. r=jgilbert (2c957a8294)
- Bug 1240438 - Fix WebGL2 framebuffer attachment related implementation. r=jgilbert (b4339241c8)
- Bug 1239187 - Use the GLFeature instead. - r=jrmuizel (c5f2c57646)
- Bug 1094458 - Implement RenderbufferStorageMultisample. - r=jrmuizel (f20f776597)
- Bug 1246007 - Ignore RENDERBUFFER_SAMPLES outside of webgl2. - r=jrmuizel (6b8f59ae49)
- Bug 1243907 - Don't query _BITS enums on Core profiles. - r=jrmuizel (e722abe45b)
- partial Bug 1242120 - Remove switch fallthrough (0f47fb7a71)
- Bug 1236080. Null check format in GetParameter. r=jgilbert (09fedc2ea8)
- Bug 1240662 - Add max level check for framebufferTextureLayer. r=jgilbert (f6d5eda15c)
- Bug 1236091. Move validate checks inside of null checks. r=jgilbert (4c67e04e87)
- Bug 1237191 - Add check for getQueryParameter to return correct error. r=jgilbert (93345aab7e)
- Bug 1230089 - If sampler is bound, use parameter of sampler. r=jgilbert (e4139a5174)
- Bug 1242336 - Fix WebGL2 return type of GL_UNPACK_SKIP. r=jgilbert (4a2ef1956e)
- Bug 1240262 - Annotate intentional switch fallthrough and suppress -Wimplicit-fallthrough warnings in dom/canvas/. r=jgilbert (eaee57ba8f)
- Bug 1237194 - Fix getSyncParameter return error. r=jgilbert (13119be06e)
- Bug 1239541 - Fix WebGL2 texImage related checking. r=jgilbert (6777244db0)
- Bug 1225291 - IsTransformFeedback doesn't report error when input is null. r=jgilbert (8c67d072b5)
- Bug 1233094. Handle null buffers in GetIndexedParameter. r=jgilbert (ae5d75bd47)
- Bug 1228676 - WebGL2 VertexAttrib funcs should match WebGL 1 patterns. - r=jgilbert (bf96c0e17b)
- Bug 1237420 - "Fix length-checking when setting WebGL 2 vertex attributes with an array". r=jgilbert (d8e9ca7111)
- Bug 1233819 - Fix WebGL on WinXP. - r=jrmuizel (39b15ba9ee)
- Bug 1233046 - Mark non-try platforms. Align some tests. (9d16ce70a4)
- Bug 1201885,1247752,1247753 - Re-mark passing/failing tests. (381c71c0f8)
- Bug 1247764 - Disable STENCIL_TEST on mac+intel when not needed. - r=jrmuizel (0b544d0c36)
- Bug 1243908 - Use DrawBuffers through GLScreenBuffer when operating on fb0. - r=jrmuizel (0ac0fc6047)
- Bug 1229944 - Add glClear for zeroing texture data. - r=kamidphish (51df8cbb50)
- Bug 1220450 - Clear length on cache OOM. r=kamidphish (44431a0d3e)
- Bug 1232346 - Clarify ResolveForDraw's failure checking. - r=kamidphish (542917bb85)
444 lines
12 KiB
C++
444 lines
12 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "nsIClassInfoImpl.h"
|
|
#include "nsThreadPool.h"
|
|
#include "nsThreadManager.h"
|
|
#include "nsThread.h"
|
|
#include "nsMemory.h"
|
|
#include "nsAutoPtr.h"
|
|
#include "prinrval.h"
|
|
#include "mozilla/Logging.h"
|
|
#include "nsThreadSyncDispatch.h"
|
|
|
|
using namespace mozilla;
|
|
|
|
static LazyLogModule sThreadPoolLog("nsThreadPool");
|
|
#ifdef LOG
|
|
#undef LOG
|
|
#endif
|
|
#define LOG(args) MOZ_LOG(sThreadPoolLog, mozilla::LogLevel::Debug, args)
|
|
|
|
// DESIGN:
|
|
// o Allocate anonymous threads.
|
|
// o Use nsThreadPool::Run as the main routine for each thread.
|
|
// o Each thread waits on the event queue's monitor, checking for
|
|
// pending events and rescheduling itself as an idle thread.
|
|
|
|
#define DEFAULT_THREAD_LIMIT 4
|
|
#define DEFAULT_IDLE_THREAD_LIMIT 1
|
|
#define DEFAULT_IDLE_THREAD_TIMEOUT PR_SecondsToInterval(60)
|
|
|
|
NS_IMPL_ADDREF(nsThreadPool)
|
|
NS_IMPL_RELEASE(nsThreadPool)
|
|
NS_IMPL_CLASSINFO(nsThreadPool, nullptr, nsIClassInfo::THREADSAFE,
|
|
NS_THREADPOOL_CID)
|
|
NS_IMPL_QUERY_INTERFACE_CI(nsThreadPool, nsIThreadPool, nsIEventTarget,
|
|
nsIRunnable)
|
|
NS_IMPL_CI_INTERFACE_GETTER(nsThreadPool, nsIThreadPool, nsIEventTarget)
|
|
|
|
nsThreadPool::nsThreadPool()
|
|
: mMutex("[nsThreadPool.mMutex]")
|
|
, mEvents(mMutex)
|
|
, mThreadLimit(DEFAULT_THREAD_LIMIT)
|
|
, mIdleThreadLimit(DEFAULT_IDLE_THREAD_LIMIT)
|
|
, mIdleThreadTimeout(DEFAULT_IDLE_THREAD_TIMEOUT)
|
|
, mIdleCount(0)
|
|
, mStackSize(nsIThreadManager::DEFAULT_STACK_SIZE)
|
|
, mShutdown(false)
|
|
{
|
|
LOG(("THRD-P(%p) constructor!!!\n", this));
|
|
}
|
|
|
|
nsThreadPool::~nsThreadPool()
|
|
{
|
|
// Threads keep a reference to the nsThreadPool until they return from Run()
|
|
// after removing themselves from mThreads.
|
|
MOZ_ASSERT(mThreads.IsEmpty());
|
|
}
|
|
|
|
nsresult
|
|
nsThreadPool::PutEvent(nsIRunnable* aEvent)
|
|
{
|
|
nsCOMPtr<nsIRunnable> event(aEvent);
|
|
return PutEvent(event.forget());
|
|
}
|
|
|
|
nsresult
|
|
nsThreadPool::PutEvent(already_AddRefed<nsIRunnable>&& aEvent)
|
|
{
|
|
// Avoid spawning a new thread while holding the event queue lock...
|
|
|
|
bool spawnThread = false;
|
|
uint32_t stackSize = 0;
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
|
|
if (NS_WARN_IF(mShutdown)) {
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
}
|
|
LOG(("THRD-P(%p) put [%d %d %d]\n", this, mIdleCount, mThreads.Count(),
|
|
mThreadLimit));
|
|
MOZ_ASSERT(mIdleCount <= (uint32_t)mThreads.Count(), "oops");
|
|
|
|
// Make sure we have a thread to service this event.
|
|
if (mThreads.Count() < (int32_t)mThreadLimit &&
|
|
// Spawn a new thread if we don't have enough idle threads to serve
|
|
// pending events immediately.
|
|
mEvents.Count(lock) >= mIdleCount) {
|
|
spawnThread = true;
|
|
}
|
|
|
|
mEvents.PutEvent(Move(aEvent), lock);
|
|
stackSize = mStackSize;
|
|
}
|
|
|
|
LOG(("THRD-P(%p) put [spawn=%d]\n", this, spawnThread));
|
|
if (!spawnThread) {
|
|
return NS_OK;
|
|
}
|
|
|
|
nsCOMPtr<nsIThread> thread;
|
|
nsThreadManager::get()->NewThread(0,
|
|
stackSize,
|
|
getter_AddRefs(thread));
|
|
if (NS_WARN_IF(!thread)) {
|
|
return NS_ERROR_UNEXPECTED;
|
|
}
|
|
|
|
bool killThread = false;
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
if (mThreads.Count() < (int32_t)mThreadLimit) {
|
|
mThreads.AppendObject(thread);
|
|
} else {
|
|
killThread = true; // okay, we don't need this thread anymore
|
|
}
|
|
}
|
|
LOG(("THRD-P(%p) put [%p kill=%d]\n", this, thread.get(), killThread));
|
|
if (killThread) {
|
|
// We never dispatched any events to the thread, so we can shut it down
|
|
// asynchronously without worrying about anything.
|
|
ShutdownThread(thread);
|
|
} else {
|
|
thread->Dispatch(this, NS_DISPATCH_NORMAL);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
void
|
|
nsThreadPool::ShutdownThread(nsIThread* aThread)
|
|
{
|
|
LOG(("THRD-P(%p) shutdown async [%p]\n", this, aThread));
|
|
|
|
// This is either called by a threadpool thread that is out of work, or
|
|
// a thread that attempted to create a threadpool thread and raced in
|
|
// such a way that the newly created thread is no longer necessary.
|
|
// In the first case, we must go to another thread to shut aThread down
|
|
// (because it is the current thread). In the second case, we cannot
|
|
// synchronously shut down the current thread (because then Dispatch() would
|
|
// spin the event loop, and that could blow up the world), and asynchronous
|
|
// shutdown requires this thread have an event loop (and it may not, see bug
|
|
// 10204784). The simplest way to cover all cases is to asynchronously
|
|
// shutdown aThread from the main thread.
|
|
nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod(aThread,
|
|
&nsIThread::AsyncShutdown);
|
|
NS_DispatchToMainThread(r);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::Run()
|
|
{
|
|
mThreadNaming.SetThreadPoolName(mName);
|
|
|
|
LOG(("THRD-P(%p) enter %s\n", this, mName.BeginReading()));
|
|
|
|
nsCOMPtr<nsIThread> current;
|
|
nsThreadManager::get()->GetCurrentThread(getter_AddRefs(current));
|
|
|
|
bool shutdownThreadOnExit = false;
|
|
bool exitThread = false;
|
|
bool wasIdle = false;
|
|
PRIntervalTime idleSince;
|
|
|
|
nsCOMPtr<nsIThreadPoolListener> listener;
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
listener = mListener;
|
|
}
|
|
|
|
if (listener) {
|
|
listener->OnThreadCreated();
|
|
}
|
|
|
|
do {
|
|
nsCOMPtr<nsIRunnable> event;
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
|
|
if (!mEvents.GetPendingEvent(getter_AddRefs(event), lock)) {
|
|
PRIntervalTime now = PR_IntervalNow();
|
|
PRIntervalTime timeout = PR_MillisecondsToInterval(mIdleThreadTimeout);
|
|
|
|
// If we are shutting down, then don't keep any idle threads
|
|
if (mShutdown) {
|
|
exitThread = true;
|
|
} else {
|
|
if (wasIdle) {
|
|
// if too many idle threads or idle for too long, then bail.
|
|
if (mIdleCount > mIdleThreadLimit ||
|
|
(mIdleThreadTimeout != UINT32_MAX && (now - idleSince) >= timeout)) {
|
|
exitThread = true;
|
|
}
|
|
} else {
|
|
// if would be too many idle threads...
|
|
if (mIdleCount == mIdleThreadLimit) {
|
|
exitThread = true;
|
|
} else {
|
|
++mIdleCount;
|
|
idleSince = now;
|
|
wasIdle = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (exitThread) {
|
|
if (wasIdle) {
|
|
--mIdleCount;
|
|
}
|
|
shutdownThreadOnExit = mThreads.RemoveObject(current);
|
|
} else {
|
|
PRIntervalTime delta = timeout - (now - idleSince);
|
|
LOG(("THRD-P(%p) %s waiting [%d]\n", this, mName.BeginReading(), delta));
|
|
mEvents.Wait(delta);
|
|
LOG(("THRD-P(%p) done waiting\n", this));
|
|
}
|
|
} else if (wasIdle) {
|
|
wasIdle = false;
|
|
--mIdleCount;
|
|
}
|
|
}
|
|
if (event) {
|
|
LOG(("THRD-P(%p) %s running [%p]\n", this, mName.BeginReading(), event.get()));
|
|
event->Run();
|
|
}
|
|
} while (!exitThread);
|
|
|
|
if (listener) {
|
|
listener->OnThreadShuttingDown();
|
|
}
|
|
|
|
if (shutdownThreadOnExit) {
|
|
ShutdownThread(current);
|
|
}
|
|
|
|
LOG(("THRD-P(%p) leave\n", this));
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::DispatchFromScript(nsIRunnable* aEvent, uint32_t aFlags)
|
|
{
|
|
nsCOMPtr<nsIRunnable> event(aEvent);
|
|
return Dispatch(event.forget(), aFlags);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::Dispatch(already_AddRefed<nsIRunnable>&& aEvent, uint32_t aFlags)
|
|
{
|
|
LOG(("THRD-P(%p) dispatch [%p %x]\n", this, /* XXX aEvent*/ nullptr, aFlags));
|
|
|
|
if (NS_WARN_IF(mShutdown)) {
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
}
|
|
|
|
if (aFlags & DISPATCH_SYNC) {
|
|
nsCOMPtr<nsIThread> thread;
|
|
nsThreadManager::get()->GetCurrentThread(getter_AddRefs(thread));
|
|
if (NS_WARN_IF(!thread)) {
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
}
|
|
|
|
RefPtr<nsThreadSyncDispatch> wrapper =
|
|
new nsThreadSyncDispatch(thread, Move(aEvent));
|
|
PutEvent(wrapper);
|
|
|
|
while (wrapper->IsPending()) {
|
|
NS_ProcessNextEvent(thread);
|
|
}
|
|
} else {
|
|
NS_ASSERTION(aFlags == NS_DISPATCH_NORMAL, "unexpected dispatch flags");
|
|
PutEvent(Move(aEvent));
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::IsOnCurrentThread(bool* aResult)
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
if (NS_WARN_IF(mShutdown)) {
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
}
|
|
|
|
nsIThread* thread = NS_GetCurrentThread();
|
|
for (uint32_t i = 0; i < static_cast<uint32_t>(mThreads.Count()); ++i) {
|
|
if (mThreads[i] == thread) {
|
|
*aResult = true;
|
|
return NS_OK;
|
|
}
|
|
}
|
|
*aResult = false;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::Shutdown()
|
|
{
|
|
nsCOMArray<nsIThread> threads;
|
|
nsCOMPtr<nsIThreadPoolListener> listener;
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
mShutdown = true;
|
|
mEvents.NotifyAll();
|
|
|
|
threads.AppendObjects(mThreads);
|
|
mThreads.Clear();
|
|
|
|
// Swap in a null listener so that we release the listener at the end of
|
|
// this method. The listener will be kept alive as long as the other threads
|
|
// that were created when it was set.
|
|
mListener.swap(listener);
|
|
}
|
|
|
|
// It's important that we shutdown the threads while outside the event queue
|
|
// monitor. Otherwise, we could end up dead-locking.
|
|
|
|
for (int32_t i = 0; i < threads.Count(); ++i) {
|
|
threads[i]->Shutdown();
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::GetThreadLimit(uint32_t* aValue)
|
|
{
|
|
*aValue = mThreadLimit;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::SetThreadLimit(uint32_t aValue)
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
LOG(("THRD-P(%p) thread limit [%u]\n", this, aValue));
|
|
mThreadLimit = aValue;
|
|
if (mIdleThreadLimit > mThreadLimit) {
|
|
mIdleThreadLimit = mThreadLimit;
|
|
}
|
|
|
|
if (static_cast<uint32_t>(mThreads.Count()) > mThreadLimit) {
|
|
mEvents.NotifyAll(); // wake up threads so they observe this change
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::GetIdleThreadLimit(uint32_t* aValue)
|
|
{
|
|
*aValue = mIdleThreadLimit;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::SetIdleThreadLimit(uint32_t aValue)
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
LOG(("THRD-P(%p) idle thread limit [%u]\n", this, aValue));
|
|
mIdleThreadLimit = aValue;
|
|
if (mIdleThreadLimit > mThreadLimit) {
|
|
mIdleThreadLimit = mThreadLimit;
|
|
}
|
|
|
|
// Do we need to kill some idle threads?
|
|
if (mIdleCount > mIdleThreadLimit) {
|
|
mEvents.NotifyAll(); // wake up threads so they observe this change
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::GetIdleThreadTimeout(uint32_t* aValue)
|
|
{
|
|
*aValue = mIdleThreadTimeout;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::SetIdleThreadTimeout(uint32_t aValue)
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
uint32_t oldTimeout = mIdleThreadTimeout;
|
|
mIdleThreadTimeout = aValue;
|
|
|
|
// Do we need to notify any idle threads that their sleep time has shortened?
|
|
if (mIdleThreadTimeout < oldTimeout && mIdleCount > 0) {
|
|
mEvents.NotifyAll(); // wake up threads so they observe this change
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::GetThreadStackSize(uint32_t* aValue)
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
*aValue = mStackSize;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::SetThreadStackSize(uint32_t aValue)
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
mStackSize = aValue;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::GetListener(nsIThreadPoolListener** aListener)
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
NS_IF_ADDREF(*aListener = mListener);
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::SetListener(nsIThreadPoolListener* aListener)
|
|
{
|
|
nsCOMPtr<nsIThreadPoolListener> swappedListener(aListener);
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
mListener.swap(swappedListener);
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsThreadPool::SetName(const nsACString& aName)
|
|
{
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
if (mThreads.Count()) {
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
}
|
|
}
|
|
|
|
mName = aName;
|
|
return NS_OK;
|
|
}
|