本文整理汇总了C++中TransactionThreadPool::Dispatch方法的典型用法代码示例。如果您正苦于以下问题:C++ TransactionThreadPool::Dispatch方法的具体用法?C++ TransactionThreadPool::Dispatch怎么用?C++ TransactionThreadPool::Dispatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TransactionThreadPool
的用法示例。
在下文中一共展示了TransactionThreadPool::Dispatch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CommitHelper
nsresult
IDBTransaction::CommitOrRollback()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!IndexedDatabaseManager::IsMainProcess()) {
NS_ASSERTION(mActorChild, "Must have an actor!");
mActorChild->SendAllRequestsFinished();
return NS_OK;
}
nsRefPtr<CommitHelper> helper =
new CommitHelper(this, mListener, mCreatedObjectStores);
TransactionThreadPool* pool = TransactionThreadPool::GetOrCreate();
NS_ENSURE_STATE(pool);
mCachedStatements.Enumerate(DoomCachedStatements, helper);
NS_ASSERTION(!mCachedStatements.Count(), "Statements left!");
nsresult rv = pool->Dispatch(this, helper, true, helper);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
示例2:
NS_IMETHODIMP
TransactionPoolEventTarget::Dispatch(nsIRunnable* aRunnable,
PRUint32 aFlags)
{
NS_ASSERTION(aRunnable, "Null pointer!");
NS_ASSERTION(aFlags == NS_DISPATCH_NORMAL, "Unsupported!");
TransactionThreadPool* pool = TransactionThreadPool::GetOrCreate();
return pool->Dispatch(mTransaction, aRunnable, false, nsnull);
}
示例3:
NS_IMETHODIMP
TransactionPoolEventTarget::Dispatch(nsIRunnable* aRunnable,
uint32_t aFlags)
{
NS_ASSERTION(aRunnable, "Null pointer!");
NS_ASSERTION(aFlags == NS_DISPATCH_NORMAL, "Unsupported!");
TransactionThreadPool* pool = TransactionThreadPool::GetOrCreate();
NS_ENSURE_TRUE(pool, NS_ERROR_UNEXPECTED);
nsresult rv = pool->Dispatch(mTransaction, aRunnable, false, nullptr);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
示例4: IDBTransaction
// static
already_AddRefed<IDBTransaction>
IDBTransaction::Create(IDBDatabase* aDatabase,
nsTArray<nsString>& aObjectStoreNames,
Mode aMode,
bool aDispatchDelayed)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
nsRefPtr<IDBTransaction> transaction = new IDBTransaction();
transaction->BindToOwner(aDatabase);
if (!transaction->SetScriptOwner(aDatabase->GetScriptOwner())) {
return nsnull;
}
transaction->mDatabase = aDatabase;
transaction->mMode = aMode;
transaction->mDatabaseInfo = aDatabase->Info();
if (!transaction->mObjectStoreNames.AppendElements(aObjectStoreNames)) {
NS_ERROR("Out of memory!");
return nsnull;
}
if (!transaction->mCachedStatements.Init()) {
NS_ERROR("Failed to initialize hash!");
return nsnull;
}
if (!aDispatchDelayed) {
nsCOMPtr<nsIAppShell> appShell = do_GetService(kAppShellCID);
NS_ENSURE_TRUE(appShell, nsnull);
nsresult rv = appShell->RunBeforeNextEvent(transaction);
NS_ENSURE_SUCCESS(rv, nsnull);
transaction->mCreating = true;
}
if (aMode != IDBTransaction::VERSION_CHANGE) {
TransactionThreadPool* pool = TransactionThreadPool::GetOrCreate();
pool->Dispatch(transaction, &gStartTransactionRunnable, false, nsnull);
}
return transaction.forget();
}
示例5: runnable
NS_IMETHODIMP
IDBCursor::Continue(const jsval &aKey,
JSContext* aCx,
PRUint8 aOptionalArgCount,
PRBool* _retval)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!mObjectStore->TransactionIsOpen()) {
return NS_ERROR_UNEXPECTED;
}
if (mContinueCalled) {
return NS_ERROR_NOT_AVAILABLE;
}
Key key;
nsresult rv = IDBObjectStore::GetKeyFromJSVal(aKey, key);
NS_ENSURE_SUCCESS(rv, rv);
if (key.IsNull()) {
if (aOptionalArgCount) {
return NS_ERROR_INVALID_ARG;
}
else {
key = Key::UNSETKEY;
}
}
TransactionThreadPool* pool = TransactionThreadPool::GetOrCreate();
NS_ENSURE_TRUE(pool, NS_ERROR_FAILURE);
nsRefPtr<ContinueRunnable> runnable(new ContinueRunnable(this, key));
rv = pool->Dispatch(mTransaction, runnable, false, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
mTransaction->OnNewRequest();
mContinueCalled = true;
*_retval = PR_TRUE;
return NS_OK;
}
示例6: helper
nsresult
IDBTransaction::CommitOrRollback()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
TransactionThreadPool* pool = TransactionThreadPool::GetOrCreate();
NS_ENSURE_STATE(pool);
nsRefPtr<CommitHelper> helper(new CommitHelper(this, mListener,
mCreatedObjectStores));
mCachedStatements.Enumerate(DoomCachedStatements, helper);
NS_ASSERTION(!mCachedStatements.Count(), "Statements left!");
nsresult rv = pool->Dispatch(this, helper, true, helper);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
示例7: if
// static
already_AddRefed<IDBTransaction>
IDBTransaction::CreateInternal(IDBDatabase* aDatabase,
nsTArray<nsString>& aObjectStoreNames,
Mode aMode,
bool aDispatchDelayed,
bool aIsVersionChangeTransactionChild)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(IndexedDatabaseManager::IsMainProcess() || !aDispatchDelayed,
"No support for delayed-dispatch transactions in child "
"process!");
NS_ASSERTION(!aIsVersionChangeTransactionChild ||
(!IndexedDatabaseManager::IsMainProcess() &&
aMode == IDBTransaction::VERSION_CHANGE),
"Busted logic!");
nsRefPtr<IDBTransaction> transaction = new IDBTransaction();
transaction->BindToOwner(aDatabase);
if (!transaction->SetScriptOwner(aDatabase->GetScriptOwner())) {
return nsnull;
}
transaction->mDatabase = aDatabase;
transaction->mMode = aMode;
transaction->mDatabaseInfo = aDatabase->Info();
transaction->mObjectStoreNames.AppendElements(aObjectStoreNames);
transaction->mObjectStoreNames.Sort();
IndexedDBTransactionChild* actor = nsnull;
transaction->mCreatedFileInfos.Init();
if (IndexedDatabaseManager::IsMainProcess()) {
transaction->mCachedStatements.Init();
if (aMode != IDBTransaction::VERSION_CHANGE) {
TransactionThreadPool* pool = TransactionThreadPool::GetOrCreate();
NS_ENSURE_TRUE(pool, nsnull);
pool->Dispatch(transaction, &gStartTransactionRunnable, false, nsnull);
}
}
else if (!aIsVersionChangeTransactionChild) {
IndexedDBDatabaseChild* dbActor = aDatabase->GetActorChild();
NS_ASSERTION(dbActor, "Must have an actor here!");
ipc::NormalTransactionParams params;
params.names().AppendElements(aObjectStoreNames);
params.mode() = aMode;
actor = new IndexedDBTransactionChild();
dbActor->SendPIndexedDBTransactionConstructor(actor, params);
}
if (!aDispatchDelayed) {
nsCOMPtr<nsIAppShell> appShell = do_GetService(kAppShellCID);
NS_ENSURE_TRUE(appShell, nsnull);
nsresult rv = appShell->RunBeforeNextEvent(transaction);
NS_ENSURE_SUCCESS(rv, nsnull);
transaction->mCreating = true;
}
if (actor) {
NS_ASSERTION(!IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
actor->SetTransaction(transaction);
}
return transaction.forget();
}