You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bs...@apache.org on 2015/08/21 23:22:58 UTC
[34/51] [partial] incubator-geode git commit: GEODE-77 removing the
old jgroups subproject
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/TimeoutException.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/TimeoutException.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/TimeoutException.java
deleted file mode 100644
index c178aac..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/TimeoutException.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/** Notice of modification as required by the LGPL
- * This file was modified by Gemstone Systems Inc. on
- * $Date$
- **/
-/*
- File: TimeoutException.java
-
- Originally written by Doug Lea and released into the public domain.
- This may be used for any purposes whatsoever without acknowledgment.
- Thanks for the assistance and support of Sun Microsystems Labs,
- and everyone contributing, testing, and using this code.
-
- History:
- Date Who What
- 29Jun1998 dl Create public version
- 4Aug1998 dl Change to extend InterruptedException
-*/
-
-package com.gemstone.org.jgroups.oswego.concurrent;
-
-/**
- * Thrown by synchronization classes that report
- * timeouts via exceptions. The exception is treated
- * as a form (subclass) of InterruptedException. This both
- * simplifies handling, and conceptually reflects the fact that
- * timed-out operations are artificially interrupted by timers.
- **/
-
-public class TimeoutException extends InterruptedException {
-private static final long serialVersionUID = -123312260478918288L;
-
- /**
- * The approximate time that the operation lasted before
- * this timeout exception was thrown.
- **/
-
- public final long duration;
- /**
- * Constructs a TimeoutException with given duration value.
- **/
- public TimeoutException(long time) {
- duration = time;
- }
-
- /**
- * Constructs a TimeoutException with the
- * specified duration value and detail message.
- */
- public TimeoutException(long time, String message) {
- super(message);
- duration = time;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/TimeoutSync.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/TimeoutSync.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/TimeoutSync.java
deleted file mode 100644
index f1e0b36..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/TimeoutSync.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/** Notice of modification as required by the LGPL
- * This file was modified by Gemstone Systems Inc. on
- * $Date$
- **/
-/*
- File: TimeoutSync.java
-
- Originally written by Doug Lea and released into the public domain.
- This may be used for any purposes whatsoever without acknowledgment.
- Thanks for the assistance and support of Sun Microsystems Labs,
- and everyone contributing, testing, and using this code.
-
- History:
- Date Who What
- 1Aug1998 dl Create public version
-*/
-
-package com.gemstone.org.jgroups.oswego.concurrent;
-
-/**
- * A TimeoutSync is an adaptor class that transforms all
- * calls to acquire to instead invoke attempt with a predetermined
- * timeout value.
- *<p>
- * <b>Sample Usage</b>. A TimeoutSync can be used to obtain
- * Timeouts for locks used in SyncCollections. For example:
- * <pre>
- * Mutex lock = new Mutex();
- * TimeoutSync timedLock = new TimeoutSync(lock, 1000); // 1 sec timeouts
- * Set set = new SyncSet(new HashSet(), timedlock);
- * try {
- * set. add("hi");
- * }
- * // SyncSets translate timeouts and other lock failures
- * // to unsupported operation exceptions,
- * catch (UnsupportedOperationException ex) {
- * System.out.println("Lock failure");
- * }
- * </pre>
- *
- * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
- * @see Sync
-**/
-
-
-public class TimeoutSync implements Sync {
-
- protected final Sync sync_; // the adapted sync
- protected final long timeout_; // timeout value
-
- /**
- * Create a TimeoutSync using the given Sync object, and
- * using the given timeout value for all calls to acquire.
- **/
-
- public TimeoutSync(Sync sync, long timeout) {
- sync_ = sync;
- timeout_ = timeout;
- }
-
- public void acquire() throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition for safety
- if (!sync_.attempt(timeout_)) throw new TimeoutException(timeout_);
- }
-
- public boolean attempt(long msecs) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition for safety
- return sync_.attempt(msecs);
- }
-
- public void release() {
- sync_.release();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/VetoableChangeMulticaster.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/VetoableChangeMulticaster.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/VetoableChangeMulticaster.java
deleted file mode 100644
index 441ad18..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/VetoableChangeMulticaster.java
+++ /dev/null
@@ -1,577 +0,0 @@
-/** Notice of modification as required by the LGPL
- * This file was modified by Gemstone Systems Inc. on
- * $Date$
- **/
-/*
- File: ProperyChangeMulticaster.java
-
- Originally written by Doug Lea and released into the public domain.
- This may be used for any purposes whatsoever without acknowledgment.
- Thanks for the assistance and support of Sun Microsystems Labs,
- and everyone contributing, testing, and using this code.
-
- This class is based on Sun JDK java.beans.VetoableChangeSupport,
- which is copyrighted by Sun. (It shares practically no code, but for
- consistency, the documentation was lifted and adapted here.)
-
- History:
- Date Who What
- 14Mar1999 dl first release
-*/
-
-package com.gemstone.org.jgroups.oswego.concurrent;
-
-import java.beans.VetoableChangeListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyVetoException;
-import java.util.HashMap;
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
-import java.io.IOException;
-
-/**
- * This class is interoperable with java.beans.VetoableChangeSupport,
- * but relies on a streamlined copy-on-write scheme similar to
- * that used in CopyOnWriteArrayList. It also adheres to clarified
- * semantics of add, remove, and fireVetoableChange operations.
- * <p>
- * <b>Sample usage.</b>
- *
- * <pre>
- * class Thing {
- * protected Color myColor = Color.red; // an example property
- * protected boolean changePending; // track whether in midst of change
- *
- * // vetoable listeners:
- * protected VetoableChangeMulticaster vetoers =
- * new VetoableChangeMulticaster(this);
- *
- * // Possibly also some ordinary listeners:
- * protected PropertyChangeMulticaster listeners =
- * new PropertyChangeMulticaster(this);
- *
- * // registration methods, including:
- * void addVetoer(VetoableChangeListener l) {
- * // Use the `ifAbsent' version to avoid duplicate notifications
- * vetoers.addVetoableChangeListenerIfAbsent(l);
- * }
- *
- * public synchronized Color getColor() { // accessor
- * return myColor;
- * }
- *
- * // Simple transactional control for vetos
- *
- * public void setColor(int newColor) throws PropertyVetoException {
- * Color oldColor = prepareSetColor(newColor);
- *
- * try {
- * vetoers.fireVetoableChange("color", oldColor, newColor);
- * commitColor(newColor);
- * listeners.firePropertyChange("color", oldColor, newColor);
- * }
- * catch(PropertyVetoException ex) {
- * abortSetColor();
- * throw ex;
- * }
- * }
- *
- * // Called on entry to proposed vetoable change from setColor.
- * // Throws exception if there is already another change in progress.
- * // Returns current color
- * synchronized int prepareSetColor(Color c) throws PropertyVetoException {
- * // only support one transaction at a time
- * if (changePending)
- * throw new PropertyVetoException("Concurrent modification");
- * // (Could alternatively wait out other transactions via
- * // a wait/notify construction based on changePending.)
- *
- * // perhaps some other screenings, like:
- * else if (c == null)
- * throw new PropertyVetoException("Cannot change color to Null");
- * else {
- * changePending = true;
- * return myColor;
- * }
- * }
- *
- * synchronized void commitColor(Color newColor) {
- * myColor = newColor;
- * changePending = false;
- * }
- *
- * synchronized void abortSetColor() {
- * changePending = false;
- * }
- *
- * }
- * </pre>
- * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
- **/
-
-public class VetoableChangeMulticaster implements Serializable {
- private static final long serialVersionUID = 7647606497666380264L;
-
- // This code is 90% identical with PropertyChangeMulticaster,
- // but there is no good way to unify the code while maintaining
- // interoperability with beans versions.
-
- /**
- * The array of listeners. Copied on each update
- **/
-
- protected transient VetoableChangeListener[] listeners = new VetoableChangeListener[0];
-
-
- /**
- * The object to be provided as the "source" for any generated events.
- * @serial
- */
- protected final Object source;
-
- /**
- * HashMap for managing listeners for specific properties.
- * Maps property names to VetoableChangeMulticaster objects.
- * @serial
- */
- protected HashMap children;
-
- /**
- * Return the child associated with property, or null if no such
- **/
-
- protected synchronized VetoableChangeMulticaster getChild(String propertyName) {
- return (children == null)? null :
- ((VetoableChangeMulticaster)children.get(propertyName));
- }
-
-
- /**
- * Constructs a <code>VetoableChangeMulticaster</code> object.
- *
- * @param sourceBean The bean to be given as the source for any events.
- * @exception NullPointerException if sourceBean is null
- */
-
- public VetoableChangeMulticaster(Object sourceBean) {
- if (sourceBean == null) {
- throw new NullPointerException();
- }
-
- source = sourceBean;
- }
-
- /**
- * Add a VetoableChangeListener to the listener list.
- * The listener is registered for all properties.
- * If the listener is added multiple times, it will
- * receive multiple change notifications upon any fireVetoableChange.
- *
- * @param listener The VetoableChangeListener to be added
- */
-
- public synchronized void addVetoableChangeListener(VetoableChangeListener listener) {
-
- if (listener == null) throw new NullPointerException();
-
- int len = listeners.length;
- VetoableChangeListener[] newArray = new VetoableChangeListener[len + 1];
- if (len > 0)
- System.arraycopy(listeners, 0, newArray, 0, len);
- newArray[len] = listener;
- listeners = newArray;
- }
-
- /**
- * Add a PropertyChangeListener to the listener list if it is
- * not already present.
- * The listener is registered for all properties.
- * The operation maintains Set semantics: If the listener is already
- * registered, the operation has no effect.
- *
- * @param listener The PropertyChangeListener to be added
- * @exception NullPointerException If listener is null
- */
-
- public synchronized void addVetoableChangeListenerIfAbsent(VetoableChangeListener listener) {
-
- if (listener == null) throw new NullPointerException();
-
- // Copy while checking if already present.
- int len = listeners.length;
- VetoableChangeListener[] newArray = new VetoableChangeListener[len + 1];
- for (int i = 0; i < len; ++i) {
- newArray[i] = listeners[i];
- if (listener.equals(listeners[i]))
- return; // already present -- throw away copy
- }
- newArray[len] = listener;
- listeners = newArray;
- }
-
-
- /**
- * Remove an occurrence of a VetoableChangeListener from the listener list.
- * It removes at most one occurrence of the given listener.
- * If the listener was added multiple times it must be removed
- * mulitple times.
- * This removes a VetoableChangeListener that was registered
- * for all properties, and has no effect if registered for only
- * one or more specified properties.
- *
- * @param listener The VetoableChangeListener to be removed
- */
-
- public synchronized void removeVetoableChangeListener(VetoableChangeListener listener) {
-
- int newlen = listeners.length-1;
- if (newlen < 0 || listener == null) return;
-
- // Copy while searching for element to remove
-
- VetoableChangeListener[] newArray = new VetoableChangeListener[newlen];
-
- for (int i = 0; i < newlen; ++i) {
- if (listener.equals(listeners[i])) {
- // copy remaining and exit
- for (int k = i + 1; k <= newlen; ++k) newArray[k-1] = listeners[k];
- listeners = newArray;
- return;
- }
- else
- newArray[i] = listeners[i];
- }
-
- // special-case last cell
- if (listener.equals(listeners[newlen]))
- listeners = newArray;
-
- }
-
- /**
- * Add a VetoableChangeListener for a specific property. The listener
- * will be invoked only when a call on fireVetoableChange names that
- * specific property. However, if a listener is registered both for all
- * properties and a specific property, it will receive multiple
- * notifications upon changes to that property.
- *
- * @param propertyName The name of the property to listen on.
- * @param listener The VetoableChangeListener to be added
- * @exception NullPointerException If listener is null
- */
-
- public void addVetoableChangeListener(String propertyName,
- VetoableChangeListener listener) {
-
- if (listener == null) throw new NullPointerException();
-
- VetoableChangeMulticaster child = null;
-
- synchronized(this) {
- if (children == null)
- children = new HashMap();
- else
- child = (VetoableChangeMulticaster)children.get(propertyName);
-
- if (child == null) {
- child = new VetoableChangeMulticaster(source);
- children.put(propertyName, child);
- }
- }
-
- child.addVetoableChangeListener(listener);
- }
-
- /**
- * Add a VetoableChangeListener for a specific property, if it is not
- * already registered. The listener
- * will be invoked only when a call on fireVetoableChange names that
- * specific property.
- *
- * @param propertyName The name of the property to listen on.
- * @param listener The VetoableChangeListener to be added
- * @exception NullPointerException If listener is null
- */
-
- public void addVetoableChangeListenerIfAbsent(String propertyName,
- VetoableChangeListener listener) {
-
- if (listener == null) throw new NullPointerException();
-
- VetoableChangeMulticaster child = null;
-
- synchronized(this) {
- if (children == null)
- children = new HashMap();
- else
- child = (VetoableChangeMulticaster)children.get(propertyName);
-
- if (child == null) {
- child = new VetoableChangeMulticaster(source);
- children.put(propertyName, child);
- }
- }
-
- child.addVetoableChangeListenerIfAbsent(listener);
- }
-
-
- /**
- * Remove a VetoableChangeListener for a specific property.
- * Affects only the given property.
- * If the listener is also registered for all properties,
- * then it will continue to be registered for them.
- *
- * @param propertyName The name of the property that was listened on.
- * @param listener The VetoableChangeListener to be removed
- */
-
- public void removeVetoableChangeListener(String propertyName,
- VetoableChangeListener listener) {
-
- VetoableChangeMulticaster child = getChild(propertyName);
- if (child != null)
- child.removeVetoableChangeListener(listener);
- }
-
-
- /**
- * Helper method to relay evt to all listeners.
- * Called by all public fireVetoableChange methods.
- **/
-
- protected void multicast(PropertyChangeEvent evt) throws PropertyVetoException {
-
- VetoableChangeListener[] array; // bind in synch block below
- VetoableChangeMulticaster child = null;
-
- synchronized (this) {
- array = listeners;
-
- if (children != null && evt.getPropertyName() != null)
- child = (VetoableChangeMulticaster)children.get(evt.getPropertyName());
- }
-
- // Loop through array, and then cascade to child.
-
- int i = 0; // make visible to catch clause
-
- try {
- for (i = 0; i < array.length; ++i)
- array[i].vetoableChange(evt);
-
- if (child != null)
- child.multicast(evt);
- }
-
- catch (PropertyVetoException veto) {
-
- // Revert all that have been notified
-
- PropertyChangeEvent revert =
- new PropertyChangeEvent(evt.getSource(),
- evt.getPropertyName(),
- evt.getNewValue(),
- evt.getOldValue());
-
- int lastNotified = (i < array.length)? i : (array.length-1);
-
- for (int k = 0; k <= lastNotified; ++k) {
- try {
- array[k].vetoableChange(revert);
- }
- catch (PropertyVetoException ignore) {
- // Cannot veto a reversion
- }
- }
-
- // Rethrow the PropertyVetoException.
- throw veto;
- }
- }
-
-
- /**
- * Report a vetoable property update to any registered listeners.
- * Notifications are sent serially (although in no particular order)
- * to the list of listeners,
- * aborting if one throws PropertyVetoException. Upon this exception,
- * fire a new event reverting this
- * change to all listeners that have already been notified
- * (ignoring any further vetos),
- * suppress notifications to all other listeners, and
- * then rethrow the PropertyVetoException.
- * <p>
- * No event is fired if old and new are equal non-null.
- *
- * @param propertyName The programmatic name of the property
- * that was changed.
- * @param oldValue The old value of the property.
- * @param newValue The new value of the property.
- * @exception PropertyVetoException if a recipient wishes the property
- * change to be rolled back.
- */
- public void fireVetoableChange(String propertyName,
- Object oldValue, Object newValue) throws PropertyVetoException {
-
- if (oldValue == null || newValue == null || !oldValue.equals(newValue)) {
- multicast(new PropertyChangeEvent(source,
- propertyName,
- oldValue,
- newValue));
- }
-
- }
-
- /**
- * Report a vetoable property update to any registered listeners.
- * Notifications are sent serially (although in no particular order)
- * to the list of listeners,
- * aborting if one throws PropertyVetoException. Upon this exception,
- * fire a new event reverting this
- * change to all listeners that have already been notified
- * (ignoring any further vetos),
- * suppress notifications to all other listeners, and
- * then rethrow the PropertyVetoException.
- * <p>
- * No event is fired if old and new are equal.
- * <p>
- * This is merely a convenience wrapper around the more general
- * fireVetoableChange method that takes Object values.
- *
- * @param propertyName The programmatic name of the property
- * that was changed.
- * @param oldValue The old value of the property.
- * @param newValue The new value of the property.
- * @exception PropertyVetoException if the recipient wishes the property
- * change to be rolled back.
- */
- public void fireVetoableChange(String propertyName,
- int oldValue, int newValue) throws PropertyVetoException {
- if (oldValue != newValue) {
- multicast(new PropertyChangeEvent(source,
- propertyName,
- Integer.valueOf(oldValue),
- Integer.valueOf(newValue)));
- }
- }
-
-
- /**
- * Report a vetoable property update to any registered listeners.
- * Notifications are sent serially (although in no particular order)
- * to the list of listeners,
- * aborting if one throws PropertyVetoException. Upon this exception,
- * fire a new event reverting this
- * change to all listeners that have already been notified
- * (ignoring any further vetos),
- * suppress notifications to all other listeners, and
- * then rethrow the PropertyVetoException.
- * <p>
- * No event is fired if old and new are equal.
- * <p>
- * This is merely a convenience wrapper around the more general
- * fireVetoableChange method that takes Object values.
- *
- * @param propertyName The programmatic name of the property
- * that was changed.
- * @param oldValue The old value of the property.
- * @param newValue The new value of the property.
- * @exception PropertyVetoException if the recipient wishes the property
- * change to be rolled back.
- */
- public void fireVetoableChange(String propertyName,
- boolean oldValue, boolean newValue) throws PropertyVetoException {
- if (oldValue != newValue) {
- multicast(new PropertyChangeEvent(source,
- propertyName,
- Boolean.valueOf(oldValue), // GemStoneAddition
- Boolean.valueOf(newValue))); // GemStoneAddition
- }
- }
-
- /**
- * Report a vetoable property update to any registered listeners.
- * Notifications are sent serially (although in no particular order)
- * to the list of listeners,
- * aborting if one throws PropertyVetoException. Upon this exception,
- * fire a new event reverting this
- * change to all listeners that have already been notified
- * (ignoring any further vetos),
- * suppress notifications to all other listeners, and
- * then rethrow the PropertyVetoException.
- * <p>
- * No event is fired if old and new are equal and non-null.
- *
- * equal and non-null.
- * @param evt The PropertyChangeEvent object.
- * @exception PropertyVetoException if the recipient wishes the property
- * change to be rolled back.
- */
- public void fireVetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
- Object oldValue = evt.getOldValue();
- Object newValue = evt.getNewValue();
- if (oldValue == null || newValue == null || !oldValue.equals(newValue))
- multicast(evt);
- }
-
- /**
- * Check if there are any listeners for a specific property.
- * If propertyName is null, return whether there are any listeners at all.
- *
- * @param propertyName the property name.
- * @return true if there are one or more listeners for the given property
- *
- */
- public boolean hasListeners(String propertyName) {
-
- VetoableChangeMulticaster child;
-
- synchronized (this) {
- if (listeners.length > 0)
- return true;
- else if (propertyName == null || children == null)
- return false;
- else {
- child = (VetoableChangeMulticaster)children.get(propertyName);
- if (child == null)
- return false;
- }
- }
-
- return child.hasListeners(null);
- }
-
-
- /**
- * @serialData Null terminated list of <code>VetoableChangeListeners</code>.
- * <p>
- * At serialization time we skip non-serializable listeners and
- * only serialize the serializable listeners.
- *
- */
- private synchronized void writeObject(ObjectOutputStream s) throws IOException {
- s.defaultWriteObject();
-
- for (int i = 0; i < listeners.length; i++) {
-// VetoableChangeListener l = listeners[i]; GemStoneAddition
- if (listeners[i] instanceof Serializable) {
- s.writeObject(listeners[i]);
- }
- }
- s.writeObject(null);
- }
-
-
- private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
- listeners = new VetoableChangeListener[0]; // paranoically reset
- s.defaultReadObject();
-
- Object listenerOrNull;
- while (null != (listenerOrNull = s.readObject())) {
- addVetoableChangeListener((VetoableChangeListener)listenerOrNull);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitFreeQueue.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitFreeQueue.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitFreeQueue.java
deleted file mode 100644
index e638bf5..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitFreeQueue.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/** Notice of modification as required by the LGPL
- * This file was modified by Gemstone Systems Inc. on
- * $Date$
- **/
-/*
- File: WaitFreeQueue.java
-
- Originally written by Doug Lea and released into the public domain.
- This may be used for any purposes whatsoever without acknowledgment.
- Thanks for the assistance and support of Sun Microsystems Labs,
- and everyone contributing, testing, and using this code.
-
- History:
- Date Who What
- 16Jun1998 dl Create public version
- 5Aug1998 dl replaced int counters with longs
- 17nov2001 dl Simplify given Bill Pugh's observation
- that counted pointers are unnecessary.
-*/
-
-package com.gemstone.org.jgroups.oswego.concurrent;
-
-/**
- * A wait-free linked list based queue implementation.
- * <p>
- *
- * While this class conforms to the full Channel interface, only the
- * <code>put</code> and <code>poll</code> methods are useful in most
- * applications. Because the queue does not support blocking
- * operations, <code>take</code> relies on spin-loops, which can be
- * extremely wasteful. <p>
- *
- * This class is adapted from the algorithm described in <a
- * href="http://www.cs.rochester.edu/u/michael/PODC96.html"> Simple,
- * Fast, and Practical Non-Blocking and Blocking Concurrent Queue
- * Algorithms</a> by Maged M. Michael and Michael L. Scott. This
- * implementation is not strictly wait-free since it relies on locking
- * for basic atomicity and visibility requirements. Locks can impose
- * unbounded waits, although this should not be a major practical
- * concern here since each lock is held for the duration of only a few
- * statements. (However, the overhead of using so many locks can make
- * it less attractive than other Channel implementations on JVMs where
- * locking operations are very slow.) <p>
- *
- * @see BoundedLinkedQueue
- * @see LinkedQueue
- *
- * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
-
- **/
-
-public class WaitFreeQueue implements Channel {
-
- /*
- This is a straightforward adaptation of Michael & Scott
- algorithm, with CAS's simulated via per-field locks,
- and without version numbers for pointers since, under
- Java Garbage Collection, you can never see the "wrong"
- node with the same address as the one you think you have.
- */
-
- /** List nodes for Queue **/
- protected final static class Node {
- protected final Object value;
- protected volatile Node next;
-
- /** Make a new node with indicated item, and null link **/
- protected Node(Object x) { value = x; }
-
- /** Simulate a CAS operation for 'next' field **/
- protected synchronized boolean CASNext(Node oldNext, Node newNext) {
- if (next == oldNext) {
- next = newNext;
- return true;
- }
- else
- return false;
- }
- }
-
- /** Head of list is always a dummy node **/
- protected volatile Node head = new Node(null);
- /** Pointer to last node on list **/
- protected volatile Node tail = head;
-
- /** Lock for simulating CAS for tail field **/
- protected final Object tailLock = new Object();
-
- /** Simulate CAS for head field, using 'this' lock **/
- protected synchronized boolean CASHead(Node oldHead, Node newHead) {
- if (head == oldHead) {
- head = newHead;
- return true;
- }
- else
- return false;
- }
-
- /** Simulate CAS for tail field **/
- protected boolean CASTail(Node oldTail, Node newTail) {
- synchronized(tailLock) {
- if (tail == oldTail) {
- tail = newTail;
- return true;
- }
- else
- return false;
- }
- }
-
- public void put(Object x) throws InterruptedException {
- if (x == null) throw new IllegalArgumentException();
- if (Thread.interrupted()) throw new InterruptedException();
- Node n = new Node(x);
-
- for(;;) {
- Node t = tail;
- // Try to link new node to end of list.
- if (t.CASNext(null, n)) {
- // Must now change tail field.
- // This CAS might fail, but if so, it will be fixed by others.
- CASTail(t, n);
- return;
- }
-
- // If cannot link, help out a previous failed attempt to move tail
- CASTail(t, t.next);
- }
- }
-
- public boolean offer(Object x, long msecs) throws InterruptedException {
-// if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition not necessary checked in put
- put(x);
- return true;
- }
-
- /** Main dequeue algorithm, called by poll, take. **/
- protected Object extract() throws InterruptedException {
- for (;;) {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- Node h = head;
- Node first = h.next;
-
- if (first == null)
- return null;
-
- Object result = first.value;
- if (CASHead(h, first))
- return result;
- }
- }
-
- public Object peek() {
- Node first = head.next;
-
- if (first == null)
- return null;
-
- // Note: This synch unnecessary after JSR-133.
- // It exists only to guarantee visibility of returned object,
- // No other synch is needed, but "old" memory model requires one.
- synchronized(this) {
- return first.value;
- }
- }
-
- /**
- * Spin until poll returns a non-null value.
- * You probably don't want to call this method.
- * A Thread.sleep(0) is performed on each iteration
- * as a heuristic to reduce contention. If you would
- * rather use, for example, an exponential backoff,
- * you could manually set this up using poll.
- **/
- public Object take() throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException();
- for(;;) {
- Object x = extract();
- if (x != null)
- return x;
- else
- Thread.sleep(0);
- }
- }
-
- /**
- * Spin until poll returns a non-null value or time elapses.
- * if msecs is positive, a Thread.sleep(0) is performed on each iteration
- * as a heuristic to reduce contention.
- **/
- public Object poll(long msecs) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException();
- if (msecs <= 0)
- return extract();
-
- long startTime = System.currentTimeMillis();
- for(;;) {
- Object x = extract();
- if (x != null)
- return x;
- else if (System.currentTimeMillis() - startTime >= msecs)
- return null;
- else
- Thread.sleep(0);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableBoolean.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableBoolean.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableBoolean.java
deleted file mode 100644
index d66d225..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableBoolean.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/** Notice of modification as required by the LGPL
- * This file was modified by Gemstone Systems Inc. on
- * $Date$
- **/
-/*
- File: WaitableBoolean.java
-
- Originally written by Doug Lea and released into the public domain.
- This may be used for any purposes whatsoever without acknowledgment.
- Thanks for the assistance and support of Sun Microsystems Labs,
- and everyone contributing, testing, and using this code.
-
- History:
- Date Who What
- 19Jun1998 dl Create public version
-*/
-
-package com.gemstone.org.jgroups.oswego.concurrent;
-
-/**
- * A class useful for offloading synch for boolean instance variables.
- *
- * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
- **/
-
-public class WaitableBoolean extends SynchronizedBoolean {
-
- /** Make a new WaitableBoolean with the given initial value **/
- public WaitableBoolean(boolean initialValue) { super(initialValue); }
-
-
- /**
- * Make a new WaitableBoolean with the given initial value,
- * and using the supplied lock.
- **/
- public WaitableBoolean(boolean initialValue, Object lock) {
- super(initialValue, lock);
- }
-
-
- @Override // GemStoneAddition
- public boolean set(boolean newValue) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.set(newValue);
- }
- }
-
- @Override // GemStoneAddition
- public boolean commit(boolean assumedValue, boolean newValue) {
- synchronized (lock_) {
- boolean success = super.commit(assumedValue, newValue);
- if (success) lock_.notifyAll();
- return success;
- }
- }
-
- @Override // GemStoneAddition
- public boolean complement() {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.complement();
- }
- }
-
- @Override // GemStoneAddition
- public boolean and(boolean b) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.and(b);
- }
- }
-
- @Override // GemStoneAddition
- public boolean or(boolean b) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.or(b);
- }
- }
-
- @Override // GemStoneAddition
- public boolean xor(boolean b) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.xor(b);
- }
- }
-
- /**
- * Wait until value is false, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
-
- public void whenFalse(Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (value_) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value is true, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenTrue(Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!value_) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * Wait until value equals c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
-
- public void whenEqual(boolean c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ == c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value not equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenNotEqual(boolean c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ != c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableByte.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableByte.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableByte.java
deleted file mode 100644
index e3e7070..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableByte.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/** Notice of modification as required by the LGPL
- * This file was modified by Gemstone Systems Inc. on
- * $Date$
- **/
-/*
- File: WaitableByte.java
-
- Originally written by Doug Lea and released into the public domain.
- This may be used for any purposes whatsoever without acknowledgment.
- Thanks for the assistance and support of Sun Microsystems Labs,
- and everyone contributing, testing, and using this code.
-
- History:
- Date Who What
- 23Jun1998 dl Create public version
- 13may2004 dl Add notifying bit ops
-*/
-
-package com.gemstone.org.jgroups.oswego.concurrent;
-
-/**
- * A class useful for offloading waiting and signalling operations
- * on single byte variables.
- * <p>
- * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
- **/
-
-public class WaitableByte extends SynchronizedByte {
- /**
- * Make a new WaitableByte with the given initial value,
- * and using its own internal lock.
- **/
- public WaitableByte(byte initialValue) {
- super(initialValue);
- }
-
- /**
- * Make a new WaitableByte with the given initial value,
- * and using the supplied lock.
- **/
- public WaitableByte(byte initialValue, Object lock) {
- super(initialValue, lock);
- }
-
-
- @Override // GemStoneAddition
- public byte set(byte newValue) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.set(newValue);
- }
- }
-
- @Override // GemStoneAddition
- public boolean commit(byte assumedValue, byte newValue) {
- synchronized (lock_) {
- boolean success = super.commit(assumedValue, newValue);
- if (success) lock_.notifyAll();
- return success;
- }
- }
-
- @Override // GemStoneAddition
- public byte increment() {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.increment();
- }
- }
-
- @Override // GemStoneAddition
- public byte decrement() {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.decrement();
- }
- }
-
- @Override // GemStoneAddition
- public byte add(byte amount) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.add(amount);
- }
- }
-
- @Override // GemStoneAddition
- public byte subtract(byte amount) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.subtract(amount);
- }
- }
-
- @Override // GemStoneAddition
- public byte multiply(byte factor) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.multiply(factor);
- }
- }
-
- @Override // GemStoneAddition
- public byte divide(byte factor) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.divide(factor);
- }
- }
-
- /**
- * Set the value to its complement
- * @return the new value
- **/
- @Override // GemStoneAddition
- public byte complement() {
- synchronized (lock_) {
- value_ = (byte)~value_;
- lock_.notifyAll();
- return value_;
- }
- }
-
- /**
- * Set value to value & b.
- * @return the new value
- **/
- @Override // GemStoneAddition
- public byte and(byte b) {
- synchronized (lock_) {
- value_ = (byte)(value_ & b);
- lock_.notifyAll();
- return value_;
- }
- }
-
- /**
- * Set value to value | b.
- * @return the new value
- **/
- @Override // GemStoneAddition
- public byte or(byte b) {
- synchronized (lock_) {
- value_ = (byte)(value_ | b);
- lock_.notifyAll();
- return value_;
- }
- }
-
-
- /**
- * Set value to value ^ b.
- * @return the new value
- **/
- @Override // GemStoneAddition
- public byte xor(byte b) {
- synchronized (lock_) {
- value_ = (byte)(value_ ^ b);
- lock_.notifyAll();
- return value_;
- }
- }
-
- /**
- * Wait until value equals c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
-
- public void whenEqual(byte c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized(lock_) {
- while (!(value_ == c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value not equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenNotEqual(byte c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ != c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value less than or equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenLessEqual(byte c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ <= c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value less than c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenLess(byte c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ < c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value greater than or equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenGreaterEqual(byte c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ >= c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value greater than c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenGreater(byte c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ > c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableChar.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableChar.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableChar.java
deleted file mode 100644
index 1905b06..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableChar.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/** Notice of modification as required by the LGPL
- * This file was modified by Gemstone Systems Inc. on
- * $Date$
- **/
-/*
- File: WaitableChar.java
-
- Originally written by Doug Lea and released into the public domain.
- This may be used for any purposes whatsoever without acknowledgment.
- Thanks for the assistance and support of Sun Microsystems Labs,
- and everyone contributing, testing, and using this code.
-
- History:
- Date Who What
- 23Jun1998 dl Create public version
-*/
-
-package com.gemstone.org.jgroups.oswego.concurrent;
-
-/**
- * A class useful for offloading waiting and signalling operations
- * on single char variables.
- * <p>
- * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
- **/
-
-public class WaitableChar extends SynchronizedChar {
- /**
- * Make a new WaitableChar with the given initial value,
- * and using its own internal lock.
- **/
- public WaitableChar(char initialValue) {
- super(initialValue);
- }
-
- /**
- * Make a new WaitableChar with the given initial value,
- * and using the supplied lock.
- **/
- public WaitableChar(char initialValue, Object lock) {
- super(initialValue, lock);
- }
-
-
- @Override // GemStoneAddition
- public char set(char newValue) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.set(newValue);
- }
- }
-
- @Override // GemStoneAddition
- public boolean commit(char assumedValue, char newValue) {
- synchronized (lock_) {
- boolean success = super.commit(assumedValue, newValue);
- if (success) lock_.notifyAll();
- return success;
- }
- }
-
-
- @Override // GemStoneAddition
- public char add(char amount) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.add(amount);
- }
- }
-
- @Override // GemStoneAddition
- public char subtract(char amount) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.subtract(amount);
- }
- }
-
- @Override // GemStoneAddition
- public char multiply(char factor) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.multiply(factor);
- }
- }
-
- @Override // GemStoneAddition
- public char divide(char factor) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.divide(factor);
- }
- }
-
-
- /**
- * Wait until value equals c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
-
- public void whenEqual(char c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized(lock_) {
- while (!(value_ == c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value not equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenNotEqual(char c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ != c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value less than or equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenLessEqual(char c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ <= c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value less than c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenLess(char c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ < c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value greater than or equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenGreaterEqual(char c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ >= c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value greater than c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenGreater(char c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ > c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableDouble.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableDouble.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableDouble.java
deleted file mode 100644
index 24c2656..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableDouble.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/** Notice of modification as required by the LGPL
- * This file was modified by Gemstone Systems Inc. on
- * $Date$
- **/
-/*
- File: WaitableDouble.java
-
- Originally written by Doug Lea and released into the public domain.
- This may be used for any purposes whatsoever without acknowledgment.
- Thanks for the assistance and support of Sun Microsystems Labs,
- and everyone contributing, testing, and using this code.
-
- History:
- Date Who What
- 23Jun1998 dl Create public version
-*/
-
-package com.gemstone.org.jgroups.oswego.concurrent;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
-/**
- * A class useful for offloading waiting and signalling operations
- * on single double variables.
- * <p>
- * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
- **/
-
-public class WaitableDouble extends SynchronizedDouble {
- /**
- * Make a new WaitableDouble with the given initial value,
- * and using its own internal lock.
- **/
- public WaitableDouble(double initialValue) {
- super(initialValue);
- }
-
- /**
- * Make a new WaitableDouble with the given initial value,
- * and using the supplied lock.
- **/
- public WaitableDouble(double initialValue, Object lock) {
- super(initialValue, lock);
- }
-
-
- @Override // GemStoneAddition
- public double set(double newValue) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.set(newValue);
- }
- }
-
- @Override // GemStoneAddition
- public boolean commit(double assumedValue, double newValue) {
- synchronized (lock_) {
- boolean success = super.commit(assumedValue, newValue);
- if (success) lock_.notifyAll();
- return success;
- }
- }
-
-
- @Override // GemStoneAddition
- public double add(double amount) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.add(amount);
- }
- }
-
- @Override // GemStoneAddition
- public double subtract(double amount) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.subtract(amount);
- }
- }
-
- @Override // GemStoneAddition
- public double multiply(double factor) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.multiply(factor);
- }
- }
-
- @Override // GemStoneAddition
- public double divide(double factor) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.divide(factor);
- }
- }
-
-
- /**
- * Wait until value equals c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- @SuppressFBWarnings(value="FE_FLOATING_POINT_EQUALITY", justification="GemFire does not use this class")
- public void whenEqual(double c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized(lock_) {
- while (!(value_ == c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value not equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- @SuppressFBWarnings(value="FE_FLOATING_POINT_EQUALITY", justification="GemFire does not use this class")
- public void whenNotEqual(double c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ != c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value less than or equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenLessEqual(double c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ <= c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value less than c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenLess(double c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ < c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value greater than or equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenGreaterEqual(double c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ >= c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value greater than c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenGreater(double c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ > c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableFloat.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableFloat.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableFloat.java
deleted file mode 100644
index 12d05b1..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableFloat.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/** Notice of modification as required by the LGPL
- * This file was modified by Gemstone Systems Inc. on
- * $Date$
- **/
-/*
- File: WaitableFloat.java
-
- Originally written by Doug Lea and released into the public domain.
- This may be used for any purposes whatsoever without acknowledgment.
- Thanks for the assistance and support of Sun Microsystems Labs,
- and everyone contributing, testing, and using this code.
-
- History:
- Date Who What
- 23Jun1998 dl Create public version
-*/
-
-package com.gemstone.org.jgroups.oswego.concurrent;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
-/**
- * A class useful for offloading waiting and signalling operations
- * on single float variables.
- * <p>
- * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
- **/
-
-public class WaitableFloat extends SynchronizedFloat {
- /**
- * Make a new WaitableFloat with the given initial value,
- * and using its own internal lock.
- **/
- public WaitableFloat(float initialValue) {
- super(initialValue);
- }
-
- /**
- * Make a new WaitableFloat with the given initial value,
- * and using the supplied lock.
- **/
- public WaitableFloat(float initialValue, Object lock) {
- super(initialValue, lock);
- }
-
-
- @Override // GemStoneAddition
- public float set(float newValue) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.set(newValue);
- }
- }
-
- @Override // GemStoneAddition
- public boolean commit(float assumedValue, float newValue) {
- synchronized (lock_) {
- boolean success = super.commit(assumedValue, newValue);
- if (success) lock_.notifyAll();
- return success;
- }
- }
-
-
- @Override // GemStoneAddition
- public float add(float amount) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.add(amount);
- }
- }
-
- @Override // GemStoneAddition
- public float subtract(float amount) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.subtract(amount);
- }
- }
-
- @Override // GemStoneAddition
- public float multiply(float factor) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.multiply(factor);
- }
- }
-
- @Override // GemStoneAddition
- public float divide(float factor) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.divide(factor);
- }
- }
-
-
- /**
- * Wait until value equals c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- @SuppressFBWarnings(value="FE_FLOATING_POINT_EQUALITY", justification="GemFire does not use this class")
- public void whenEqual(float c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized(lock_) {
- while (!(value_ == c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value not equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- @SuppressFBWarnings(value="FE_FLOATING_POINT_EQUALITY", justification="GemFire does not use this class")
- public void whenNotEqual(float c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ != c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value less than or equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenLessEqual(float c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ <= c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value less than c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenLess(float c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ < c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value greater than or equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenGreaterEqual(float c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ >= c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value greater than c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenGreater(float c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ > c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableInt.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableInt.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableInt.java
deleted file mode 100644
index bc2bfdd..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableInt.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/** Notice of modification as required by the LGPL
- * This file was modified by Gemstone Systems Inc. on
- * $Date$
- **/
-/*
- File: WaitableInt.java
-
- Originally written by Doug Lea and released into the public domain.
- This may be used for any purposes whatsoever without acknowledgment.
- Thanks for the assistance and support of Sun Microsystems Labs,
- and everyone contributing, testing, and using this code.
-
- History:
- Date Who What
- 23Jun1998 dl Create public version
- 13may2004 dl Add notifying bit ops
-*/
-
-package com.gemstone.org.jgroups.oswego.concurrent;
-
-/**
- * A class useful for offloading waiting and signalling operations
- * on single int variables.
- * <p>
- * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
- **/
-
-public class WaitableInt extends SynchronizedInt {
- /**
- * Make a new WaitableInt with the given initial value,
- * and using its own internal lock.
- **/
- public WaitableInt(int initialValue) {
- super(initialValue);
- }
-
- /**
- * Make a new WaitableInt with the given initial value,
- * and using the supplied lock.
- **/
- public WaitableInt(int initialValue, Object lock) {
- super(initialValue, lock);
- }
-
-
- @Override // GemStoneAddition
- public int set(int newValue) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.set(newValue);
- }
- }
-
- @Override // GemStoneAddition
- public boolean commit(int assumedValue, int newValue) {
- synchronized (lock_) {
- boolean success = super.commit(assumedValue, newValue);
- if (success) lock_.notifyAll();
- return success;
- }
- }
-
- @Override // GemStoneAddition
- public int increment() {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.increment();
- }
- }
-
- @Override // GemStoneAddition
- public int decrement() {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.decrement();
- }
- }
-
- @Override // GemStoneAddition
- public int add(int amount) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.add(amount);
- }
- }
-
- @Override // GemStoneAddition
- public int subtract(int amount) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.subtract(amount);
- }
- }
-
- @Override // GemStoneAddition
- public int multiply(int factor) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.multiply(factor);
- }
- }
-
- @Override // GemStoneAddition
- public int divide(int factor) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.divide(factor);
- }
- }
-
- /**
- * Set the value to its complement
- * @return the new value
- **/
- @Override // GemStoneAddition
- public int complement() {
- synchronized (lock_) {
- value_ = ~value_;
- lock_.notifyAll();
- return value_;
- }
- }
-
- /**
- * Set value to value & b.
- * @return the new value
- **/
- @Override // GemStoneAddition
- public int and(int b) {
- synchronized (lock_) {
- value_ = value_ & b;
- lock_.notifyAll();
- return value_;
- }
- }
-
- /**
- * Set value to value | b.
- * @return the new value
- **/
- @Override // GemStoneAddition
- public int or(int b) {
- synchronized (lock_) {
- value_ = value_ | b;
- lock_.notifyAll();
- return value_;
- }
- }
-
-
- /**
- * Set value to value ^ b.
- * @return the new value
- **/
- @Override // GemStoneAddition
- public int xor(int b) {
- synchronized (lock_) {
- value_ = value_ ^ b;
- lock_.notifyAll();
- return value_;
- }
- }
-
-
- /**
- * Wait until value equals c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
-
- public void whenEqual(int c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized(lock_) {
- while (!(value_ == c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value not equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenNotEqual(int c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ != c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value less than or equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenLessEqual(int c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ <= c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value less than c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenLess(int c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ < c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value greater than or equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenGreaterEqual(int c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ >= c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value greater than c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenGreater(int c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ > c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableLong.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableLong.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableLong.java
deleted file mode 100644
index 2c06c5f..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableLong.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/** Notice of modification as required by the LGPL
- * This file was modified by Gemstone Systems Inc. on
- * $Date$
- **/
-/*
- File: WaitableLong.java
-
- Originally written by Doug Lea and released into the public domain.
- This may be used for any purposes whatsoever without acknowledgment.
- Thanks for the assistance and support of Sun Microsystems Labs,
- and everyone contributing, testing, and using this code.
-
- History:
- Date Who What
- 23Jun1998 dl Create public version
- 13may2004 dl Add notifying bit ops
-*/
-
-package com.gemstone.org.jgroups.oswego.concurrent;
-
-/**
- * A class useful for offloading waiting and signalling operations
- * on single long variables.
- * <p>
- * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
- **/
-
-public class WaitableLong extends SynchronizedLong {
- /**
- * Make a new WaitableLong with the given initial value,
- * and using its own internal lock.
- **/
- public WaitableLong(long initialValue) {
- super(initialValue);
- }
-
- /**
- * Make a new WaitableLong with the given initial value,
- * and using the supplied lock.
- **/
- public WaitableLong(long initialValue, Object lock) {
- super(initialValue, lock);
- }
-
-
- @Override // GemStoneAddition
- public long set(long newValue) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.set(newValue);
- }
- }
-
- @Override // GemStoneAddition
- public boolean commit(long assumedValue, long newValue) {
- synchronized (lock_) {
- boolean success = super.commit(assumedValue, newValue);
- if (success) lock_.notifyAll();
- return success;
- }
- }
-
- @Override // GemStoneAddition
- public long increment() {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.increment();
- }
- }
-
- @Override // GemStoneAddition
- public long decrement() {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.decrement();
- }
- }
-
- @Override // GemStoneAddition
- public long add(long amount) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.add(amount);
- }
- }
-
- @Override // GemStoneAddition
- public long subtract(long amount) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.subtract(amount);
- }
- }
-
- @Override // GemStoneAddition
- public long multiply(long factor) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.multiply(factor);
- }
- }
-
- @Override // GemStoneAddition
- public long divide(long factor) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.divide(factor);
- }
- }
-
- /**
- * Set the value to its complement
- * @return the new value
- **/
- @Override // GemStoneAddition
- public long complement() {
- synchronized (lock_) {
- value_ = ~value_;
- lock_.notifyAll();
- return value_;
- }
- }
-
- /**
- * Set value to value & b.
- * @return the new value
- **/
- @Override // GemStoneAddition
- public long and(long b) {
- synchronized (lock_) {
- value_ = value_ & b;
- lock_.notifyAll();
- return value_;
- }
- }
-
- /**
- * Set value to value | b.
- * @return the new value
- **/
- @Override // GemStoneAddition
- public long or(long b) {
- synchronized (lock_) {
- value_ = value_ | b;
- lock_.notifyAll();
- return value_;
- }
- }
-
-
- /**
- * Set value to value ^ b.
- * @return the new value
- **/
- @Override // GemStoneAddition
- public long xor(long b) {
- synchronized (lock_) {
- value_ = value_ ^ b;
- lock_.notifyAll();
- return value_;
- }
- }
-
-
- /**
- * Wait until value equals c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
-
- public void whenEqual(long c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized(lock_) {
- while (!(value_ == c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value not equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenNotEqual(long c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ != c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value less than or equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenLessEqual(long c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ <= c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value less than c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenLess(long c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ < c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value greater than or equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenGreaterEqual(long c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ >= c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value greater than c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenGreater(long c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ > c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableRef.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableRef.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableRef.java
deleted file mode 100644
index 1f5824f..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableRef.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/** Notice of modification as required by the LGPL
- * This file was modified by Gemstone Systems Inc. on
- * $Date$
- **/
-/*
- File: WaitableRef.java
-
- Originally written by Doug Lea and released into the public domain.
- This may be used for any purposes whatsoever without acknowledgment.
- Thanks for the assistance and support of Sun Microsystems Labs,
- and everyone contributing, testing, and using this code.
-
- History:
- Date Who What
- 19Jun1998 dl Create public version
-*/
-
-package com.gemstone.org.jgroups.oswego.concurrent;
-
-/**
- * A class useful for offloading synch for Object reference instance variables.
- *
- * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
- **/
-
-public class WaitableRef extends SynchronizedRef {
-
- /**
- * Create a WaitableRef initially holding the given reference
- * and using its own internal lock.
- **/
- public WaitableRef(Object initialValue) {
- super(initialValue);
- }
-
- /**
- * Make a new WaitableRef with the given initial value,
- * and using the supplied lock.
- **/
- public WaitableRef(Object initialValue, Object lock) {
- super(initialValue, lock);
- }
-
- @Override // GemStoneAddition
- public Object set(Object newValue) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.set(newValue);
- }
- }
-
- @Override // GemStoneAddition
- public boolean commit(Object assumedValue, Object newValue) {
- synchronized (lock_) {
- boolean success = super.commit(assumedValue, newValue);
- if (success) lock_.notifyAll();
- return success;
- }
- }
-
- /**
- * Wait until value is null, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
-
- public void whenNull(Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (value_ != null) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value is nonnull, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenNotNull(Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (value_ == null) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * Wait until value equals c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
-
- public void whenEqual(Object c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ == c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value not equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenNotEqual(Object c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ != c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableShort.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableShort.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableShort.java
deleted file mode 100644
index ba6898e..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/oswego/concurrent/WaitableShort.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/** Notice of modification as required by the LGPL
- * This file was modified by Gemstone Systems Inc. on
- * $Date$
- **/
-/*
- File: WaitableShort.java
-
- Originally written by Doug Lea and released into the public domain.
- This may be used for any purposes whatsoever without acknowledgment.
- Thanks for the assistance and support of Sun Microsystems Labs,
- and everyone contributing, testing, and using this code.
-
- History:
- Date Who What
- 23Jun1998 dl Create public version
- 13may2004 dl Add notifying bit ops
-*/
-
-package com.gemstone.org.jgroups.oswego.concurrent;
-
-/**
- * A class useful for offloading waiting and signalling operations
- * on single short variables.
- * <p>
- * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
- **/
-
-public class WaitableShort extends SynchronizedShort {
- /**
- * Make a new WaitableShort with the given initial value,
- * and using its own internal lock.
- **/
- public WaitableShort(short initialValue) {
- super(initialValue);
- }
-
- /**
- * Make a new WaitableShort with the given initial value,
- * and using the supplied lock.
- **/
- public WaitableShort(short initialValue, Object lock) {
- super(initialValue, lock);
- }
-
-
- @Override // GemStoneAddition
- public short set(short newValue) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.set(newValue);
- }
- }
-
- @Override // GemStoneAddition
- public boolean commit(short assumedValue, short newValue) {
- synchronized (lock_) {
- boolean success = super.commit(assumedValue, newValue);
- if (success) lock_.notifyAll();
- return success;
- }
- }
-
- @Override // GemStoneAddition
- public short increment() {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.increment();
- }
- }
-
- @Override // GemStoneAddition
- public short decrement() {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.decrement();
- }
- }
-
- @Override // GemStoneAddition
- public short add(short amount) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.add(amount);
- }
- }
-
- @Override // GemStoneAddition
- public short subtract(short amount) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.subtract(amount);
- }
- }
-
- @Override // GemStoneAddition
- public short multiply(short factor) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.multiply(factor);
- }
- }
-
- @Override // GemStoneAddition
- public short divide(short factor) {
- synchronized (lock_) {
- lock_.notifyAll();
- return super.divide(factor);
- }
- }
-
- /**
- * Set the value to its complement
- * @return the new value
- **/
- @Override // GemStoneAddition
- public short complement() {
- synchronized (lock_) {
- value_ = (short)(~value_);
- lock_.notifyAll();
- return value_;
- }
- }
-
- /**
- * Set value to value & b.
- * @return the new value
- **/
- @Override // GemStoneAddition
- public short and(short b) {
- synchronized (lock_) {
- value_ = (short)(value_ & b);
- lock_.notifyAll();
- return value_;
- }
- }
-
- /**
- * Set value to value | b.
- * @return the new value
- **/
- @Override // GemStoneAddition
- public short or(short b) {
- synchronized (lock_) {
- value_ = (short)(value_ | b);
- lock_.notifyAll();
- return value_;
- }
- }
-
-
- /**
- * Set value to value ^ b.
- * @return the new value
- **/
- @Override // GemStoneAddition
- public short xor(short b) {
- synchronized (lock_) {
- value_ = (short)(value_ ^ b);
- lock_.notifyAll();
- return value_;
- }
- }
-
- /**
- * Wait until value equals c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
-
- public void whenEqual(short c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized(lock_) {
- while (!(value_ == c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value not equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenNotEqual(short c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ != c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value less than or equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenLessEqual(short c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ <= c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value less than c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenLess(short c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ < c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value greater than or equal to c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenGreaterEqual(short c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ >= c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
- /**
- * wait until value greater than c, then run action if nonnull.
- * The action is run with the synchronization lock held.
- **/
- public void whenGreater(short c, Runnable action) throws InterruptedException {
- if (Thread.interrupted()) throw new InterruptedException(); // GemStoneAddition
- synchronized (lock_) {
- while (!(value_ > c)) lock_.wait();
- if (action != null) action.run();
- }
- }
-
-}
-