You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Michael Dürig <md...@apache.org> on 2013/10/28 09:59:52 UTC
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/
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