Home » openjdk-7 » java.lang.invoke » [javadoc | source]
java.lang.invoke
public class: VolatileCallSite [javadoc | source]
java.lang.Object
   java.lang.invoke.CallSite
      java.lang.invoke.VolatileCallSite
A {@code VolatileCallSite} is a CallSite whose target acts like a volatile variable. An {@code invokedynamic} instruction linked to a {@code VolatileCallSite} sees updates to its call site target immediately, even if the update occurs in another thread. There may be a performance penalty for such tight coupling between threads.

Unlike {@code MutableCallSite}, there is no {@linkplain MutableCallSite#syncAll syncAll operation} on volatile call sites, since every write to a volatile variable is implicitly synchronized with reader threads.

In other respects, a {@code VolatileCallSite} is interchangeable with {@code MutableCallSite}.

Fields inherited from java.lang.invoke.CallSite:
target
Constructor:
 public VolatileCallSite(MethodType type) 
    Creates a call site with a volatile binding to its target. The initial target is set to a method handle of the given type which will throw an {@code IllegalStateException} if called.
    Parameters:
    type - the method type that this call site will have
    Throws:
    NullPointerException - if the proposed type is null
 public VolatileCallSite(MethodHandle target) 
    Creates a call site with a volatile binding to its target. The target is set to the given value.
    Parameters:
    target - the method handle that will be the initial target of the call site
    Throws:
    NullPointerException - if the proposed target is null
Method from java.lang.invoke.VolatileCallSite Summary:
dynamicInvoker,   getTarget,   setTarget
Methods from java.lang.invoke.CallSite:
checkTargetChange,   dynamicInvoker,   getTarget,   getTargetVolatile,   initializeFromJVM,   makeDynamicInvoker,   makeSite,   setTarget,   setTargetNormal,   setTargetVolatile,   type,   uninitializedCallSite
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.lang.invoke.VolatileCallSite Detail:
 public final MethodHandle dynamicInvoker() 
    {@inheritDoc}
 public final MethodHandle getTarget() 
    Returns the target method of the call site, which behaves like a {@code volatile} field of the {@code VolatileCallSite}.

    The interactions of {@code getTarget} with memory are the same as of a read from a {@code volatile} field.

    In particular, the current thread is required to issue a fresh read of the target from memory, and must not fail to see a recent update to the target by another thread.

 public  void setTarget(MethodHandle newTarget) 
    Updates the target method of this call site, as a volatile variable. The type of the new target must agree with the type of the old target.

    The interactions with memory are the same as of a write to a volatile field. In particular, any threads is guaranteed to see the updated target the next time it calls {@code getTarget}.