public void flushPendingCommandsThrough(long waitForLWSN)
{
// if we're already done writing this LWSN, just return
if (finishedLWSN >= waitForLWSN) {
return;
}
// otherwise, we need to force flush...
if (USE_GROUP_COMMIT_THREAD) {
DateTime started_waiting_at = DateTime.Now;
lock (this) {
lastWaiter = started_waiting_at;
if (firstWaiter < started_waiting_at) {
firstWaiter = started_waiting_at;
}
numWaiters++;
}
do {
if ((DateTime.Now - started_waiting_at).TotalMilliseconds > 10000) {
throw new Exception("30s flush timeout exceeded");
}
// TODO: change this use a monitor instead!
// groupCommitWorkerHndl.Set(); // wakeup the worker
// groupCommitRequestorsHndl.WaitOne();
WaitHandle.SignalAndWait(groupCommitWorkerHndl, groupCommitRequestorsHndl,1000,true);
//if (this.finishedLWSN < waitForLWSN) {
// System.Console.WriteLine("still waiting... {0} < {1}",
// this.finishedLWSN,waitForLWSN);
//}
} while (this.finishedLWSN < waitForLWSN);
} else {
// not using the group commit thread
_doWritePendingCmds();
}
}