AtomicVariable
Class
The {@var}
atomic variable handler in memory.
This class provides the reference object, and also the wrapping/unwrapping points.
This should rarely be used by syntax or third-party API - atomics are handled internally.
Unless explicitly asked for by a method (such as with an AtomicVariable
parameter)
the atomic will always be unwrapped before a call.
AtomicReference
public
Constructors
new AtomicVariable ()
ConstructorAtomicVariable
public
Methods
add (Object, Object)
MethodIndex | Type | Name |
---|---|---|
1 | Object | value |
2 | Object | atomic |
void
public static
remove (Object, Object)
MethodIndex | Type | Name |
---|---|---|
1 | Object | value |
2 | Object | atomic |
void
public static
get (Object)
MethodUnwraps the atomic reference, respecting atomic access. This is thread-safe.
Index | Type | Name |
---|---|---|
1 | Object | atomic |
Object
public static
wrap (Object)
MethodReturns the atomic-wrapped version of this object. If it is already atomic, nothing will be done to it.
If the value is null
a new AtomicVariable will be returned.
Index | Type | Name |
---|---|---|
1 | Object | object |
AtomicVariable
public static
// Randomly-generated example
final AtomicVariable variable = AtomicVariable.wrap(object);
assert variable.add(value, atomic) == null;
assert variable.remove(value, atomic) == null;
variable.get(atomic);
set (Object, Object)
MethodSets the atomic reference to the given value.
If the holder is not atomic, this will throw an error.
Index | Type | Name |
---|---|---|
1 | Object | value |
2 | Object | atomic |
void
public static
delete (Object)
MethodEmpties the atomic reference.
If the holder is not atomic, this will throw an error.
Index | Type | Name |
---|---|---|
1 | Object | atomic |
void
public static
unwrap (Object)
MethodUnwraps the given object, if it is atomic. If it is not atomic, the object will be returned untouched.
Index | Type | Name |
---|---|---|
1 | Object | object |
Object
public static