mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 03:24:26 +00:00
Bug 506959 - AsyncExecuteStatements assumes ms, but calls functions that assume microseconds
This fixes the code to use functions that expect milliseconds instead of microseconds, and updates to use the new TimeStamp and TimeDuration class. r=asuth --HG-- extra : rebase_source : 6109fd10a8cf8ca985d51137f5628ca20ccee157
This commit is contained in:
parent
b2208afdfc
commit
8222bf6e58
@ -67,7 +67,7 @@ namespace storage {
|
||||
* periods of time, and dispatching many small events to the calling thread will
|
||||
* end up blocking it.
|
||||
*/
|
||||
#define MAX_MILLISECONDS_BETWEEN_RESULTS 100
|
||||
#define MAX_MILLISECONDS_BETWEEN_RESULTS 75
|
||||
#define MAX_ROWS_PER_RESULT 15
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -202,8 +202,8 @@ AsyncExecuteStatements::AsyncExecuteStatements(StatementDataArray &aStatements,
|
||||
, mTransactionManager(nsnull)
|
||||
, mCallback(aCallback)
|
||||
, mCallingThread(::do_GetCurrentThread())
|
||||
, mMaxIntervalWait(::PR_MicrosecondsToInterval(MAX_MILLISECONDS_BETWEEN_RESULTS))
|
||||
, mIntervalStart(::PR_IntervalNow())
|
||||
, mMaxWait(TimeDuration::FromMilliseconds(MAX_MILLISECONDS_BETWEEN_RESULTS))
|
||||
, mIntervalStart(TimeStamp::Now())
|
||||
, mState(PENDING)
|
||||
, mCancelRequested(PR_FALSE)
|
||||
, mMutex(aConnection->sharedAsyncExecutionMutex)
|
||||
@ -399,9 +399,9 @@ AsyncExecuteStatements::buildAndNotifyResults(sqlite3_stmt *aStatement)
|
||||
// If we have hit our maximum number of allowed results, or if we have hit
|
||||
// the maximum amount of time we want to wait for results, notify the
|
||||
// calling thread about it.
|
||||
PRIntervalTime now = ::PR_IntervalNow();
|
||||
PRIntervalTime delta = now - mIntervalStart;
|
||||
if (mResultSet->rows() >= MAX_ROWS_PER_RESULT || delta > mMaxIntervalWait) {
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
TimeDuration delta = now - mIntervalStart;
|
||||
if (mResultSet->rows() >= MAX_ROWS_PER_RESULT || delta > mMaxWait) {
|
||||
// Notify the caller
|
||||
rv = notifyResults();
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
|
||||
#include "mozIStoragePendingStatement.h"
|
||||
#include "mozIStorageStatementCallback.h"
|
||||
@ -207,12 +208,12 @@ private:
|
||||
* The maximum amount of time we want to wait between results. Defined by
|
||||
* MAX_MILLISECONDS_BETWEEN_RESULTS and set at construction.
|
||||
*/
|
||||
const PRIntervalTime mMaxIntervalWait;
|
||||
const TimeDuration mMaxWait;
|
||||
|
||||
/**
|
||||
* The start time since our last set of results.
|
||||
*/
|
||||
PRIntervalTime mIntervalStart;
|
||||
TimeStamp mIntervalStart;
|
||||
|
||||
/**
|
||||
* Indicates our state of execution.
|
||||
|
Loading…
x
Reference in New Issue
Block a user