rather than flush any/all log messages 10 times a second, flush log messages once there are 100 of them or 10 seconds have passed, whichever comes first

This commit is contained in:
jrandom
2004-08-08 01:40:48 +00:00
committed by zzz
parent e57c010e3d
commit 9cccd0bfc9
2 changed files with 14 additions and 1 deletions

View File

@ -209,8 +209,18 @@ public class LogManager {
*
*/
void addRecord(LogRecord record) {
int numRecords = 0;
synchronized (_records) {
_records.add(record);
numRecords = _records.size();
}
if (numRecords > 100) {
// the writer waits 10 seconds *or* until we tell them to wake up
// before rereading the config and writing out any log messages
synchronized (_writer) {
_writer.notifyAll();
}
}
}

View File

@ -72,12 +72,15 @@ class LogWriter implements Runnable {
t.printStackTrace();
} finally {
try {
Thread.sleep(100);
synchronized (this) {
this.wait(10*1000);
}
} catch (InterruptedException ie) { // nop
}
}
}
private void rereadConfig() {
long now = Clock.getInstance().now();
if (now - _lastReadConfig > CONFIG_READ_ITERVAL) {