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: #include "nsHtml5TreeOpStage.h" michael@0: michael@0: nsHtml5TreeOpStage::nsHtml5TreeOpStage() michael@0: : mMutex("nsHtml5TreeOpStage mutex") michael@0: { michael@0: } michael@0: michael@0: nsHtml5TreeOpStage::~nsHtml5TreeOpStage() michael@0: { michael@0: } michael@0: michael@0: void michael@0: nsHtml5TreeOpStage::MoveOpsFrom(nsTArray& aOpQueue) michael@0: { michael@0: mozilla::MutexAutoLock autoLock(mMutex); michael@0: if (mOpQueue.IsEmpty()) { michael@0: mOpQueue.SwapElements(aOpQueue); michael@0: } else { michael@0: mOpQueue.MoveElementsFrom(aOpQueue); michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5TreeOpStage::MoveOpsAndSpeculativeLoadsTo(nsTArray& aOpQueue, michael@0: nsTArray& aSpeculativeLoadQueue) michael@0: { michael@0: mozilla::MutexAutoLock autoLock(mMutex); michael@0: if (aOpQueue.IsEmpty()) { michael@0: mOpQueue.SwapElements(aOpQueue); michael@0: } else { michael@0: aOpQueue.MoveElementsFrom(mOpQueue); michael@0: } michael@0: if (aSpeculativeLoadQueue.IsEmpty()) { michael@0: mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue); michael@0: } else { michael@0: aSpeculativeLoadQueue.MoveElementsFrom(mSpeculativeLoadQueue); michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5TreeOpStage::MoveSpeculativeLoadsFrom(nsTArray& aSpeculativeLoadQueue) michael@0: { michael@0: mozilla::MutexAutoLock autoLock(mMutex); michael@0: if (mSpeculativeLoadQueue.IsEmpty()) { michael@0: mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue); michael@0: } else { michael@0: mSpeculativeLoadQueue.MoveElementsFrom(aSpeculativeLoadQueue); michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5TreeOpStage::MoveSpeculativeLoadsTo(nsTArray& aSpeculativeLoadQueue) michael@0: { michael@0: mozilla::MutexAutoLock autoLock(mMutex); michael@0: if (aSpeculativeLoadQueue.IsEmpty()) { michael@0: mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue); michael@0: } else { michael@0: aSpeculativeLoadQueue.MoveElementsFrom(mSpeculativeLoadQueue); michael@0: } michael@0: } michael@0: michael@0: #ifdef DEBUG michael@0: void michael@0: nsHtml5TreeOpStage::AssertEmpty() michael@0: { michael@0: mozilla::MutexAutoLock autoLock(mMutex); michael@0: // This shouldn't really need the mutex michael@0: NS_ASSERTION(mOpQueue.IsEmpty(), "The stage was supposed to be empty."); michael@0: } michael@0: #endif