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
This commit is contained in:
Shawn Wilsher 2009-07-28 13:18:10 -07:00
parent ef61780206
commit 3e8d79a831
2 changed files with 9 additions and 8 deletions

View File

@ -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))

View File

@ -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.