Created
October 31, 2018 16:22
-
-
Save asutherland/9ae7125819751a477ec002a28378d6a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lambda BASED | |
bool | |
WorkerPrivate::AddHolder(WorkerHolder* aHolder, WorkerStatus aFailStatus) | |
{ | |
return mWorkerThreadAccessible.Access( | |
[this, aHolder, aFailStatus] (WorkerThreadAccessible& aData) { | |
{ | |
MutexAutoLock lock(mMutex); | |
if (mStatus >= aFailStatus) { | |
return false; | |
} | |
} | |
MOZ_ASSERT(!mHolders.Contains(aHolder), "Already know about this one!"); | |
if (aHolder->GetBehavior() == WorkerHolder::PreventIdleShutdownStart) { | |
if (!aData.mNumHoldersPreventingShutdownStart && !ModifyBusyCountFromWorker(true)) { | |
return false; | |
} | |
aData.mNumHoldersPreventingShutdownStart += 1; | |
} | |
mHolders.AppendElement(aHolder); | |
return true; | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RAII BASED | |
bool | |
WorkerPrivate::AddHolder(WorkerHolder* aHolder, WorkerStatus aFailStatus) | |
{ | |
auto data = mWorkerThreadAccessible.Access(); | |
{ | |
MutexAutoLock lock(mMutex); | |
if (mStatus >= aFailStatus) { | |
return false; | |
} | |
} | |
MOZ_ASSERT(!mHolders.Contains(aHolder), "Already know about this one!"); | |
if (aHolder->GetBehavior() == WorkerHolder::PreventIdleShutdownStart) { | |
if (!data->mNumHoldersPreventingShutdownStart && !ModifyBusyCountFromWorker(true)) { | |
return false; | |
} | |
data->mNumHoldersPreventingShutdownStart += 1; | |
} | |
mHolders.AppendElement(aHolder); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment