public abstract class Lockable<T extends Lockable<T>> extends Keyed<T>
Job
s, to prevent
overwriting in-use keys. E.g. model-building: expected to read-lock input
Frame
s, and write-lock the output Model
.
Parser should write-lock the output Frame, to guard against double-parsing.
This is a simple cooperative distributed locking scheme. Because we need
distributed locking, the normal Java locks do not work. Because
we cannot enforce good behavior, this is a cooperative scheme
only.
Supports: Modifier and Type | Field and Description |
---|---|
Key<Job>[] |
_lockers
List of Job Keys locking this Key.
|
Constructor and Description |
---|
Lockable(Key<T> key)
Create a Lockable object, if it has a
Key . |
Modifier and Type | Method and Description |
---|---|
T |
delete_and_lock()
Write-lock
this._key by job_key , and delete any prior mapping. |
T |
delete_and_lock(Job job) |
T |
delete_and_lock(Key<Job> job_key) |
void |
delete()
Write-lock 'this' and delete; blocking.
|
static void |
delete(Key key)
Write-lock key and delete; blocking.
|
Futures |
delete(Key<Job> job_key,
Futures fs)
Write-lock 'this' and delete.
|
void |
read_lock(Key<Job> job_key)
Atomically get a read-lock on this, preventing future deletes or updates
|
static void |
read_lock(Key k,
Job job)
Atomically get a read-lock on Key k, preventing future deletes or updates
|
static void |
read_lock(Key k,
Key<Job> job_key) |
void |
unlock_all()
Force-unlock (break a lock) all lockers; useful in some debug situations.
|
T |
unlock()
Atomically set a new version of self and unlock.
|
T |
unlock(Job job) |
T |
unlock(Key<Job> job_key) |
T |
unlock(Key<Job> job_key,
boolean exact) |
T |
update()
Atomically set a new version of self, without changing the locking.
|
T |
update(Job job) |
T |
update(Key<Job> job_key) |
Lockable |
write_lock()
Write-lock
this._key by job_key . |
Lockable |
write_lock(Job job) |
Lockable |
write_lock(Key<Job> job_key) |
checksum_impl, checksum, makeSchema, readAll_impl, readAll, remove_impl, remove, remove, remove, remove, writeAll_impl, writeAll
asBytes, clone, copyOver, frozenType, read, readExternal, readJSON, reloadFromBytes, toJsonString, write, writeExternal, writeJSON
public transient Key<Job>[] _lockers
_lockers[0 ]
. Can be null locker._lockers[1+]
.public Lockable write_lock()
this._key
by job_key
.
Throws IAE if the Key is already locked.public T delete_and_lock()
this._key
by job_key
, and delete any prior mapping.
Throws IAE if the Key is already locked.public static void delete(Key key)
public final void delete()
Keyed.remove_impl(Futures)
as by contract, the only difference between delete()
and Keyed.remove()
is that `delete` first write-locks `this`.public final Futures delete(Key<Job> job_key, Futures fs)
Keyed.remove_impl(Futures)
.public static void read_lock(Key k, Job job)
public void read_lock(Key<Job> job_key)
public T update()
public T unlock()
public void unlock_all()