logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Elias Ross <er...@m-qube.com>
Subject Re: Sequence count, WAS: Why concurrency?
Date Tue, 01 Feb 2005 01:01:32 GMT
On Mon, 2005-01-31 at 16:27, Curt Arnold wrote:

> and these messages were dispatched to two distinct appenders (possibly 
> of different types) and that one instance of Chainsaw was listening to 
> both, it could determine that which logging events came from the same 
> iteration of the loop.

An assign sequence number method could first check if a sequence number
was already assigned:

class LoggingEvent ... {
  public synchronized void assignNewSequenceNumber(long count) {
    if (this.sequenceNumber != 0)
      return;
    this.sequenceNumber = count;
  }
}

class ChainsawAppender {
  long seq = 0;
  public synchronized void doAppend(LoggingEvent le) {
    le.assignSequenceNumber(seq++);
  }
}

Or:

class LoggingEvent ... {
  static long count;
  private synchronized void writeObject() {
    if (this.sequenceNumber == 0) {
      synchronized (LoggingEvent.class) {
        this.sequenceNumber = count++;
      }
    }
  }
}



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message