jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dürig <mdue...@apache.org>
Subject Re: svn commit: r1535500 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/observation/ test/java/org/apache/jackrabbit/oak/plugins/mongomk/
Date Mon, 28 Oct 2013 08:59:52 GMT

On 24.10.13 9:06 , jukka@apache.org wrote:
> Author: jukka
> Date: Thu Oct 24 19:06:33 2013
> New Revision: 1535500
>
> URL: http://svn.apache.org/r1535500
> Log:
> OAK-1113: Immediate delivery of events from local commits
>
> Use the LinkedBlockingQueue from a separate listener thread to avoid the fixed scheduling
of events
> @@ -186,9 +185,11 @@ public class ChangeDispatcher {
>           }
>       }
>
> -    private void add(ChangeSet changeSet) {
> -        for (Listener l : getListeners()) {
> -            l.add(changeSet);
> +    private void add(NodeState root, CommitInfo info) {
> +        synchronized (listeners) {
> +            for (Listener l : getListeners()) {
> +                l.add(root, info);
> +            }
>           }
>       }

I don't think we need the sync. here. add() is not called concurrently 
and getListeners() returns a copy of the registered listeners.

> -        private void add(ChangeSet changeSet) {
> -            changeSets.add(changeSet);
> +        private synchronized void add(NodeState root, CommitInfo info) {
> +            if (blocked) {
> +                info = null;
> +            }
> +            if (changeSets.offer(new ChangeSet(previousRoot, root, info))) {
> +                previousRoot = root;
> +                blocked = false;
> +            } else {
> +                blocked = true;
> +            }
>           }
>       }

Also here add is not called concurrently, so no need to sync.

Michael

Mime
View raw message