ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: Locking in Project and PropertyHelper
Date Tue, 17 Jun 2008 13:29:03 GMT
On Tue, Jun 17, 2008 at 1:57 PM, Stefan Bodewig <bodewig@apache.org> wrote:
> On Tue, 17 Jun 2008, Stefan Bodewig <bodewig@apache.org> wrote:
>
>> I suggest the following changes:
>>
>> * lock the listener collection in the add/remove listener methods,
>>   in fireMessageLogged lock the listeners, clone them, give up the
>>   lock, work on the clone
>
> alternatively copy listeners on change in the add/remove cases since
> we are probably writing far more log messages than we add or remove
> listeners.  Same would apply to the delegates in PropertyHelper.

We currently do copy the listeners.
    public synchronized void addBuildListener(BuildListener listener) {
     ....
        Vector newListeners = getBuildListeners();
        newListeners.addElement(listener);
        listeners = newListeners;

Simply removing the lock on the project object would
not help as multiple threads could call the add/remove method at the same time.

We would need something like jdk5's CopyOnWriteArrayList<E> to do this
correctly.

Peter

>
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>

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


Mime
View raw message