You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2009/08/03 13:27:56 UTC
svn commit: r800310 - in
/harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent:
./ atomic/
Author: hindessm
Date: Mon Aug 3 11:27:55 2009
New Revision: 800310
URL: http://svn.apache.org/viewvc?rev=800310&view=rev
Log:
Put back most lazySet methods and minor generics fixes.
Modified:
harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/AbstractExecutorService.java
harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/ExecutorService.java
harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicBoolean.java
harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicInteger.java
harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerArray.java
harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLong.java
harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongArray.java
harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReference.java
harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceArray.java
harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
Modified: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/AbstractExecutorService.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/AbstractExecutorService.java?rev=800310&r1=800309&r2=800310&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/AbstractExecutorService.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/AbstractExecutorService.java Mon Aug 3 11:27:55 2009
@@ -59,7 +59,7 @@
/**
* the main mechanics of invokeAny.
*/
- private <T> T doInvokeAny(Collection<Callable<T>> tasks,
+ private <T> T doInvokeAny(Collection<? extends Callable<T>> tasks,
boolean timed, long nanos)
throws InterruptedException, ExecutionException, TimeoutException {
if (tasks == null)
@@ -82,7 +82,7 @@
// result, we can throw the last exception we got.
ExecutionException ee = null;
long lastTime = (timed)? System.nanoTime() : 0;
- Iterator<Callable<T>> it = tasks.iterator();
+ Iterator<? extends Callable<T>> it = tasks.iterator();
// Start one task for sure; the rest incrementally
futures.add(ecs.submit(it.next()));
@@ -134,7 +134,7 @@
}
}
- public <T> T invokeAny(Collection<Callable<T>> tasks)
+ public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
throws InterruptedException, ExecutionException {
try {
return doInvokeAny(tasks, false, 0);
@@ -144,13 +144,13 @@
}
}
- public <T> T invokeAny(Collection<Callable<T>> tasks,
+ public <T> T invokeAny(Collection<? extends Callable<T>> tasks,
long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return doInvokeAny(tasks, true, unit.toNanos(timeout));
}
- public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks)
+ public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
throws InterruptedException {
if (tasks == null)
throw new NullPointerException();
@@ -180,7 +180,7 @@
}
}
- public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks,
+ public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks,
long timeout, TimeUnit unit)
throws InterruptedException {
if (tasks == null || unit == null)
Modified: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/ExecutorService.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/ExecutorService.java?rev=800310&r1=800309&r2=800310&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/ExecutorService.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/ExecutorService.java Mon Aug 3 11:27:55 2009
@@ -258,7 +258,7 @@
* scheduled for execution
*/
- <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks)
+ <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
throws InterruptedException;
/**
@@ -288,7 +288,7 @@
* @throws RejectedExecutionException if any task cannot be scheduled
* for execution
*/
- <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks,
+ <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks,
long timeout, TimeUnit unit)
throws InterruptedException;
@@ -310,7 +310,7 @@
* @throws RejectedExecutionException if tasks cannot be scheduled
* for execution
*/
- <T> T invokeAny(Collection<Callable<T>> tasks)
+ <T> T invokeAny(Collection<? extends Callable<T>> tasks)
throws InterruptedException, ExecutionException;
/**
@@ -335,7 +335,7 @@
* @throws RejectedExecutionException if tasks cannot be scheduled
* for execution
*/
- <T> T invokeAny(Collection<Callable<T>> tasks,
+ <T> T invokeAny(Collection<? extends Callable<T>> tasks,
long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicBoolean.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicBoolean.java?rev=800310&r1=800309&r2=800310&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicBoolean.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicBoolean.java Mon Aug 3 11:27:55 2009
@@ -100,6 +100,17 @@
}
/**
+ * Eventually sets to the given value.
+ *
+ * @param newValue the new value
+ * @since 1.6
+ */
+ public final void lazySet(boolean newValue) {
+ int v = newValue ? 1 : 0;
+ unsafe.putOrderedInt(this, valueOffset, v);
+ }
+
+ /**
* Atomically sets to the given value and returns the previous value.
*
* @param newValue the new value
Modified: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicInteger.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicInteger.java?rev=800310&r1=800309&r2=800310&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicInteger.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicInteger.java Mon Aug 3 11:27:55 2009
@@ -70,6 +70,16 @@
}
/**
+ * Eventually sets to the given value.
+ *
+ * @param newValue the new value
+ * @since 1.6
+ */
+ public final void lazySet(int newValue) {
+ unsafe.putOrderedInt(this, valueOffset, newValue);
+ }
+
+ /**
* Atomically sets to the given value and returns the old value.
*
* @param newValue the new value
Modified: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerArray.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerArray.java?rev=800310&r1=800309&r2=800310&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerArray.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerArray.java Mon Aug 3 11:27:55 2009
@@ -94,6 +94,17 @@
}
/**
+ * Eventually sets the element at position {@code i} to the given value.
+ *
+ * @param i the index
+ * @param newValue the new value
+ * @since 1.6
+ */
+ public final void lazySet(int i, int newValue) {
+ unsafe.putOrderedInt(array, rawIndex(i), newValue);
+ }
+
+ /**
* Atomically sets the element at position {@code i} to the given
* value and returns the old value.
*
Modified: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java?rev=800310&r1=800309&r2=800310&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java Mon Aug 3 11:27:55 2009
@@ -99,6 +99,17 @@
public abstract void set(T obj, int newValue);
/**
+ * Eventually sets the field of the given object managed by this
+ * updater to the given updated value.
+ *
+ * @param obj An object whose field to set
+ * @param newValue the new value
+ * @since 1.6
+ */
+ public abstract void lazySet(T obj, int newValue);
+
+
+ /**
* Gets the current value held in the field of the given object managed
* by this updater.
*
@@ -285,6 +296,11 @@
unsafe.putIntVolatile(obj, offset, newValue);
}
+ public void lazySet(T obj, int newValue) {
+ if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+ unsafe.putOrderedInt(obj, offset, newValue);
+ }
+
public final int get(T obj) {
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
return unsafe.getIntVolatile(obj, offset);
Modified: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLong.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLong.java?rev=800310&r1=800309&r2=800310&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLong.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLong.java Mon Aug 3 11:27:55 2009
@@ -95,6 +95,16 @@
}
/**
+ * Eventually sets to the given value.
+ *
+ * @param newValue the new value
+ * @since 1.6
+ */
+ public final void lazySet(long newValue) {
+ unsafe.putOrderedLong(this, valueOffset, newValue);
+ }
+
+ /**
* Atomically sets to the given value and returns the old value.
*
* @param newValue the new value
Modified: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongArray.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongArray.java?rev=800310&r1=800309&r2=800310&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongArray.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongArray.java Mon Aug 3 11:27:55 2009
@@ -93,6 +93,18 @@
}
/**
+ * Eventually sets the element at position {@code i} to the given value.
+ *
+ * @param i the index
+ * @param newValue the new value
+ * @since 1.6
+ */
+ public final void lazySet(int i, long newValue) {
+ unsafe.putOrderedLong(array, rawIndex(i), newValue);
+ }
+
+
+ /**
* Atomically sets the element at position {@code i} to the given value
* and returns the old value.
*
Modified: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongFieldUpdater.java?rev=800310&r1=800309&r2=800310&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongFieldUpdater.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongFieldUpdater.java Mon Aug 3 11:27:55 2009
@@ -102,6 +102,16 @@
public abstract void set(T obj, long newValue);
/**
+ * Eventually sets the field of the given object managed by this
+ * updater to the given updated value.
+ *
+ * @param obj An object whose field to set
+ * @param newValue the new value
+ * @since 1.6
+ */
+ public abstract void lazySet(T obj, long newValue);
+
+ /**
* Gets the current value held in the field of the given object managed
* by this updater.
*
@@ -284,6 +294,11 @@
unsafe.putLongVolatile(obj, offset, newValue);
}
+ public void lazySet(T obj, long newValue) {
+ if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+ unsafe.putOrderedLong(obj, offset, newValue);
+ }
+
public long get(T obj) {
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
return unsafe.getLongVolatile(obj, offset);
Modified: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReference.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReference.java?rev=800310&r1=800309&r2=800310&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReference.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReference.java Mon Aug 3 11:27:55 2009
@@ -64,6 +64,16 @@
}
/**
+ * Eventually sets to the given value.
+ *
+ * @param newValue the new value
+ * @since 1.6
+ */
+ public final void lazySet(V newValue) {
+ unsafe.putOrderedObject(this, valueOffset, newValue);
+ }
+
+ /**
* Atomically sets the value to the given updated value
* if the current value {@code ==} the expected value.
* @param expect the expected value
Modified: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceArray.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceArray.java?rev=800310&r1=800309&r2=800310&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceArray.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceArray.java Mon Aug 3 11:27:55 2009
@@ -94,6 +94,18 @@
}
/**
+ * Eventually sets the element at position {@code i} to the given value.
+ *
+ * @param i the index
+ * @param newValue the new value
+ * @since 1.6
+ */
+ public final void lazySet(int i, E newValue) {
+ unsafe.putOrderedObject(array, rawIndex(i), newValue);
+ }
+
+
+ /**
* Atomically sets the element at position {@code i} to the given
* value and returns the old value.
*
Modified: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java?rev=800310&r1=800309&r2=800310&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java Mon Aug 3 11:27:55 2009
@@ -117,6 +117,16 @@
public abstract void set(T obj, V newValue);
/**
+ * Eventually sets the field of the given object managed by this
+ * updater to the given updated value.
+ *
+ * @param obj An object whose field to set
+ * @param newValue the new value
+ * @since 1.6
+ */
+ public abstract void lazySet(T obj, V newValue);
+
+ /**
* Gets the current value held in the field of the given object managed
* by this updater.
*
@@ -240,6 +250,14 @@
unsafe.putObjectVolatile(obj, offset, newValue);
}
+ public void lazySet(T obj, V newValue) {
+ if (obj == null || obj.getClass() != tclass || cclass != null ||
+ (newValue != null && vclass != null &&
+ vclass != newValue.getClass()))
+ updateCheck(obj, newValue);
+ unsafe.putOrderedObject(obj, offset, newValue);
+ }
+
public V get(T obj) {
if (obj == null || obj.getClass() != tclass || cclass != null)
targetCheck(obj);