Package java.util.concurrent.atomic

Examples of java.util.concurrent.atomic.AtomicBoolean.compareAndSet()


    /** Efficient way of checking whether another thread is already processing messages from sender. If that's the case,
     *  we return immediately and let the existing thread process our message (https://jira.jboss.org/jira/browse/JGRP-829).
     *  Benefit: fewer threads blocked on the same lock, these threads an be returned to the thread pool */
    protected void removeAndPassUp(Table<Message> buf, Address sender, boolean loopback, AsciiString cluster_name) {
        final AtomicBoolean processing=buf.getProcessing();
        if(!processing.compareAndSet(false, true))
            return;

        boolean remove_msgs=discard_delivered_msgs && !loopback;
        boolean released_processing=false;
        try {
View Full Code Here


                }
                deliverBatch(oob_batch);
            }

            final AtomicBoolean processing=win.getProcessing();
            if(processing.compareAndSet(false, true))
                removeAndDeliver(processing, win, batch.sender());
        }

        if(!batch.isEmpty())
            up_prot.up(batch);
View Full Code Here

                return;
            }
        }

        final AtomicBoolean processing=win.getProcessing();
        if(processing.compareAndSet(false, true))
            removeAndDeliver(processing, win, sender);
    }

    /** Called when the sender of a message is the local member. In this case, we don't need to add the message
     * to the table as the sender already did that */
 
View Full Code Here

                return;
            }
        }

        final AtomicBoolean processing=win.getProcessing();
        if(processing.compareAndSet(false, true))
            removeAndDeliver(processing, win, sender);
    }

    protected void processInternalMessage(final Table<Message> win, final Address sender) {
        // If there are other msgs, tell the regular thread pool to handle them (https://issues.jboss.org/browse/JGRP-1732)
View Full Code Here

        final AtomicBoolean processing=win.getProcessing();
        if(!win.isEmpty() && !processing.get() /* && seqno < win.getHighestReceived() */) { // commented to handle hd == hr !
            Executor pool=getTransport().getDefaultThreadPool();
            pool.execute(new Runnable() {
                public void run() {
                    if(processing.compareAndSet(false, true))
                        removeAndDeliver(processing, win, sender);
                }
            });
        }
    }
View Full Code Here

            deliverBatch(oob_batch);
        }

        final AtomicBoolean processing=win.getProcessing();
        if(processing.compareAndSet(false, true))
            removeAndDeliver(processing, win, sender);
    }


View Full Code Here

        // Efficient way of checking whether another thread is already processing messages from 'sender'.
        // If that's the case, we return immediately and let the existing thread process our message
        // (https://jira.jboss.org/jira/browse/JGRP-829). Benefit: fewer threads blocked on the same lock, these threads
        // can be returned to the thread pool
        final AtomicBoolean processing=win.getProcessing();
        if(!processing.compareAndSet(false, true)) {
            return;
        }

        boolean remove_msgs=discard_delivered_msgs && !loopback;
        boolean released_processing=false;
View Full Code Here

    protected void update(Address sender) {
        if(sender != null && !sender.equals(local_addr)) {
            AtomicBoolean heartbeat_received=timestamps.get(sender);
            if(heartbeat_received != null)
                heartbeat_received.compareAndSet(false, true);
            else
                timestamps.putIfAbsent(sender, new AtomicBoolean(true));
        }
    }
View Full Code Here

                AtomicBoolean val=entry.getValue();
                if(val == null) {
                    it.remove();
                    continue;
                }
                if(!val.compareAndSet(true, false)) {
                    log.debug("%s: haven't received a heartbeat from %s in timeout period (%d ms), adding it to suspect list",
                              local_addr, key, timeout);
                    suspects.add(key);
                }
            }
View Full Code Here

       
        final Table<Message> win=received_msgs;
        win.add(hdr.seqno, msg);

        final AtomicBoolean processing=win.getProcessing();
        if(processing.compareAndSet(false, true))
            removeAndDeliver(processing, win, sender);
    }
   
   
    protected void removeAndDeliver(final AtomicBoolean processing, Table<Message> win, Address sender) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.