Return-Path: Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 76540 invoked by uid 500); 18 Aug 2003 08:18:05 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: dev@cocoon.apache.org Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 76513 invoked from network); 18 Aug 2003 08:18:04 -0000 Received: from unknown (HELO trinity.anyware-tech.com) (217.112.237.100) by daedalus.apache.org with SMTP; 18 Aug 2003 08:18:04 -0000 Received: (qmail 2002 invoked from network); 18 Aug 2003 08:18:08 -0000 Received: from unknown (HELO anyware-tech.com) (10.1.0.254) by trinity.anyware-tech.com with SMTP; 18 Aug 2003 08:18:08 -0000 Message-ID: <3F408BBF.6040109@anyware-tech.com> Date: Mon, 18 Aug 2003 10:18:07 +0200 From: Sylvain Wallez Organization: Anyware Technologies User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: fr, en, en-us MIME-Version: 1.0 To: dev@cocoon.apache.org CC: dev@ant.apache.org Subject: Re: [OT] Build Time References: <3F3D5098.9000304@verizon.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 >>>results >>> >>> > >We allow listeners to be added and removed during event logging and we >may be running several tasks in , 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()) { ((EventListener)iter.next()).fireEvent(ev); } } 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(); newListeners.add(evl); // and replace the listener list this.listeners = newListeners; } Sylvain -- Sylvain Wallez Anyware Technologies http://www.apache.org/~sylvain http://www.anyware-tech.com { XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects } Orixo, the opensource XML business alliance - http://www.orixo.com