提交 42b1c9b7 authored 作者: Thomas Mueller's avatar Thomas Mueller

After closing a database, the writer thread will stop after 100 ms at the latest…

After closing a database, the writer thread will stop after 100 ms at the latest (instead of 1 second).
上级 96da6283
...@@ -90,24 +90,21 @@ public class WriterThread implements Runnable { ...@@ -90,24 +90,21 @@ public class WriterThread implements Runnable {
traceSystem.getTrace(Trace.LOG).error("flush", e); traceSystem.getTrace(Trace.LOG).error("flush", e);
} }
} }
// TODO log writer: could also flush the dirty cache
// when there is low activity
// TODO log writer: could also flush the dirty cache when there is // wait 0 mean wait forever, which is not what we want
// low activity wait = Math.max(wait, Constants.MIN_WRITE_DELAY);
if (wait < Constants.MIN_WRITE_DELAY) { do {
// wait 0 mean wait forever, which is not what we want // wait 100 ms at a time
wait = Constants.MIN_WRITE_DELAY; int w = Math.min(wait, 100);
}
int w = wait;
while (!stop && w >= 0) {
// only wait 100 ms at a time
int n = Math.min(w, 100);
try { try {
Thread.sleep(n); Thread.sleep(w);
} catch (InterruptedException e) { } catch (InterruptedException e) {
// ignore // ignore
} }
w -= n; wait -= w;
} } while (wait > 0 && !stop);
} }
databaseRef = null; databaseRef = null;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论