io.legaldocml.pool.UnsafeHolder Maven / Gradle / Ivy
The newest version!
package io.legaldocml.pool;
import io.legaldocml.unsafe.UnsafeHelper;
/**
* @author Jacques Militello
*/
final class UnsafeHolder implements PoolHolder {
/**
* Object to hold.
*/
private final T value;
static final long FIELD_OFFSET = UnsafeHelper.getFieldOffset(UnsafeHolder.class, "state");
/**
* internal state.
*/
int state;
UnsafeHolder(T value) {
this.value = value;
state = FREE;
}
public UnsafeHolder(T value, int state) {
this.value = value;
this.state = state;
}
/**
* {@inheritDoc}
*/
@Override
public T get() {
return this.value;
}
/**
* {@inheritDoc}
*/
@Override
public int getState() {
return this.state;
}
/**
* {@inheritDoc}
*/
@Override
public void setState(int state) {
this.state = state;
}
}