mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Make open transactions keep their DB thread alive
This commit is contained in:
parent
91db4b768c
commit
5cb526715d
@ -168,6 +168,14 @@ public:
|
||||
void OnObjectStoreCreated(const ObjectStoreInfo& aInfo);
|
||||
void OnObjectStoreRemoved(const ObjectStoreInfo& aInfo);
|
||||
|
||||
void DisableConnectionThreadTimeout() {
|
||||
mConnectionThread->DisableIdleTimeout();
|
||||
}
|
||||
|
||||
void EnableConnectionThreadTimeout() {
|
||||
mConnectionThread->EnableIdleTimeout();
|
||||
}
|
||||
|
||||
protected:
|
||||
IDBDatabaseRequest();
|
||||
~IDBDatabaseRequest();
|
||||
|
@ -84,6 +84,9 @@ void
|
||||
IDBTransactionRequest::OnNewRequest()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
if (!mPendingRequests) {
|
||||
mDatabase->DisableConnectionThreadTimeout();
|
||||
}
|
||||
++mPendingRequests;
|
||||
}
|
||||
|
||||
@ -94,6 +97,7 @@ IDBTransactionRequest::OnRequestFinished()
|
||||
NS_ASSERTION(mPendingRequests, "Mismatched calls!");
|
||||
--mPendingRequests;
|
||||
if (!mPendingRequests) {
|
||||
mDatabase->EnableConnectionThreadTimeout();
|
||||
// Commit!
|
||||
NS_NOTYETIMPLEMENTED("Implement me!");
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ USING_INDEXEDDB_NAMESPACE
|
||||
|
||||
namespace {
|
||||
|
||||
const PRUint32 kDefaultThreadTimeoutMS = 30000;
|
||||
const PRUint32 kDefaultThreadTimeoutMS = 5000;
|
||||
|
||||
class OpenDatabaseHelper : public AsyncConnectionHelper
|
||||
{
|
||||
|
@ -72,7 +72,8 @@ LazyIdleThread::LazyIdleThread(PRUint32 aIdleTimeoutMS,
|
||||
mPendingEventCount(0),
|
||||
mIdleNotificationCount(0),
|
||||
mShutdown(PR_FALSE),
|
||||
mThreadIsShuttingDown(PR_FALSE)
|
||||
mThreadIsShuttingDown(PR_FALSE),
|
||||
mIdleTimeoutEnabled(PR_TRUE)
|
||||
{
|
||||
NS_ASSERTION(mOwningThread, "This should never fail!");
|
||||
}
|
||||
@ -98,6 +99,50 @@ LazyIdleThread::SetWeakIdleObserver(nsIObserver* aObserver)
|
||||
mIdleObserver = aObserver;
|
||||
}
|
||||
|
||||
void
|
||||
LazyIdleThread::DisableIdleTimeout()
|
||||
{
|
||||
ASSERT_OWNING_THREAD();
|
||||
if (!mIdleTimeoutEnabled) {
|
||||
return;
|
||||
}
|
||||
mIdleTimeoutEnabled = PR_FALSE;
|
||||
|
||||
if (mIdleTimer && NS_FAILED(mIdleTimer->Cancel())) {
|
||||
NS_WARNING("Failed to cancel timer!");
|
||||
}
|
||||
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
// Pretend we have a pending event to keep the idle timer from firing.
|
||||
NS_ASSERTION(mPendingEventCount < PR_UINT32_MAX, "Way too many!");
|
||||
mPendingEventCount++;
|
||||
}
|
||||
|
||||
void
|
||||
LazyIdleThread::EnableIdleTimeout()
|
||||
{
|
||||
ASSERT_OWNING_THREAD();
|
||||
if (mIdleTimeoutEnabled) {
|
||||
return;
|
||||
}
|
||||
mIdleTimeoutEnabled = PR_TRUE;
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
NS_ASSERTION(mPendingEventCount, "Mismatched calls to observer methods!");
|
||||
--mPendingEventCount;
|
||||
}
|
||||
|
||||
if (mThread) {
|
||||
nsCOMPtr<nsIRunnable> runnable(new nsRunnable());
|
||||
if (NS_FAILED(Dispatch(runnable, NS_DISPATCH_NORMAL))) {
|
||||
NS_WARNING("Failed to dispatch!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LazyIdleThread::PreDispatch()
|
||||
{
|
||||
|
@ -90,6 +90,17 @@ public:
|
||||
*/
|
||||
void SetWeakIdleObserver(nsIObserver* aObserver);
|
||||
|
||||
/**
|
||||
* Disable the idle timeout for this thread. No effect if the timeout is
|
||||
* already disabled.
|
||||
*/
|
||||
void DisableIdleTimeout();
|
||||
|
||||
/**
|
||||
* Enable the idle timeout. No effect if the timeout is already enabled.
|
||||
*/
|
||||
void EnableIdleTimeout();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Calls Shutdown().
|
||||
@ -191,6 +202,11 @@ private:
|
||||
* further idle notifications during the shutdown process.
|
||||
*/
|
||||
PRPackedBool mThreadIsShuttingDown;
|
||||
|
||||
/**
|
||||
* Whether or not the idle timeout is enabled.
|
||||
*/
|
||||
PRPackedBool mIdleTimeoutEnabled;
|
||||
};
|
||||
|
||||
END_INDEXEDDB_NAMESPACE
|
||||
|
Loading…
Reference in New Issue
Block a user