TEST(WTF_Deque, MoveOnly) { Deque<MoveOnly> deque; deque.append(MoveOnly(1)); deque.prepend(MoveOnly(0)); EXPECT_EQ(0U, deque.first().value()); EXPECT_EQ(1U, deque.last().value()); auto first = deque.takeFirst(); EXPECT_EQ(0U, first.value()); auto last = deque.takeLast(); EXPECT_EQ(1U, last.value()); }
RefPtr<UniqueIDBDatabaseTransaction> UniqueIDBDatabase::takeNextRunnableTransaction(bool& hadDeferredTransactions) { Deque<RefPtr<UniqueIDBDatabaseTransaction>> deferredTransactions; RefPtr<UniqueIDBDatabaseTransaction> currentTransaction; while (!m_pendingTransactions.isEmpty()) { currentTransaction = m_pendingTransactions.takeFirst(); switch (currentTransaction->info().mode()) { case IndexedDB::TransactionMode::ReadOnly: // If there are any deferred transactions, the first one is a read-write transaction we need to unblock. // Therefore, skip this read-only transaction if its scope overlaps with that read-write transaction. if (!deferredTransactions.isEmpty()) { ASSERT(deferredTransactions.first()->info().mode() == IndexedDB::TransactionMode::ReadWrite); if (scopesOverlap(deferredTransactions.first()->objectStoreIdentifiers(), currentTransaction->objectStoreIdentifiers())) deferredTransactions.append(WTF::move(currentTransaction)); } break; case IndexedDB::TransactionMode::ReadWrite: // If this read-write transaction's scope overlaps with running transactions, it must be deferred. if (scopesOverlap(m_objectStoreTransactionCounts, currentTransaction->objectStoreIdentifiers())) deferredTransactions.append(WTF::move(currentTransaction)); break; case IndexedDB::TransactionMode::VersionChange: // Version change transactions should never be scheduled in the traditional manner. RELEASE_ASSERT_NOT_REACHED(); } // If we didn't defer the currentTransaction above, it can be run now. if (currentTransaction) break; } hadDeferredTransactions = !deferredTransactions.isEmpty(); if (!hadDeferredTransactions) return WTF::move(currentTransaction); // Prepend the deferred transactions back on the beginning of the deque for future scheduling passes. while (!deferredTransactions.isEmpty()) m_pendingTransactions.prepend(deferredTransactions.takeLast()); return WTF::move(currentTransaction); }