public class VolatileCallSite extends CallSiteA
CallSitewhose target acts like a volatile variable. An
invokedynamicinstruction linked to a
VolatileCallSitesees 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.
MutableCallSite, there is no syncAll operation on volatile call sites, since every write to a volatile variable is implicitly synchronized with reader threads.
In other respects, a
VolatileCallSiteis interchangeable with
- See Also:
All Methods Instance Methods Concrete Methods Modifier and Type Method Description
getTarget()Returns the target method of the call site, which behaves like a
volatilefield of the
setTarget(MethodHandle newTarget)Updates the target method of this call site, as a volatile variable.
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
type- the method type that this call site will have
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.
target- the method handle that will be the initial target of the call site
NullPointerException- if the proposed target is null
public final MethodHandle getTarget()Returns the target method of the call site, which behaves like a
volatilefield of the
The interactions of
getTargetwith memory are the same as of a read from a
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