cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <>
Subject Re: [OT] Build Time
Date Mon, 18 Aug 2003 08:18:07 GMT
Stefan Bodewig wrote:

>On Fri, 15 Aug 2003, Nicola Ken Barozzi <> wrote:
>>>DirectoryScanner.scandir Does somebody know anybody working on Ant
>>>logging system? Is Ant 1.6 better in this regard?
>Ant's DirectoryScanner may have become a lot (and I mean a lot) faster
>in 1.6, depending on the patterns you use.
>>>PS Removing synchronized() in this method gives even better
>We allow listeners to be added and removed during event logging and we
>may be running several tasks in <parallel>, so I'm afraid that
>removing synchronized may be doing more harm than help.
>For the same reason we clone the Vector of listeners before we start
>to fire events.  In the patched code, we'd at least have to copy the
>array and iterate over that copy to avoid problems when a listener
>removes itself in response to a logged message.

To solve this problem, you may consider the fact that listeners are more 
often fired than changed, and therefore use a different pattern, which 
does the cloning and synchronisation when the listener list has to be 
changed, and not when it has to be traversed.

private List listenerers;

public void fireEvent(Event ev) {
  Iterator iter = this.listeners.iterator();
  while(iter.hasNext()) {

public void synchronized addListener(EventListener evl) {
  // Make a local copy on which we will act : it avoids
  // ConcurrentModificationException if someone is executing fireEvent()
  List newListeners = this.listeners.clone();
  // and replace the listener list
  this.listeners = newListeners;


Sylvain Wallez                                  Anyware Technologies 
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -

View raw message