com.opendatagroup.hadrian.shared
Returns the item with a given name
at substructure path
if it exists or an exception if there are any errors.
Returns the item with a given name
at substructure path
if it exists or an exception if there are any errors.
Blocks during initialization, but never afterward. If a put
, update
, or remove
is in progress, get
returns the old version of the item; it does not wait for a new version to be provided.
name of the object to extract (could be a cell or an item of a pool)
sequence of array indexes, map keys, and record field names to extract
a tagged union (Scala Either
) of Left(exception object) or Right(result at the end of the path)
Replaces or adds an item with a given name
at substructure path
, returning value
if there are no errors or an exception otherwise.
Replaces or adds an item with a given name
at substructure path
, returning value
if there are no errors or an exception otherwise.
Blocks during initialization and during any other update (put
, update
, or remove
). Blocking is at the granularity of a particular item: if another item (with another name
) is being updated, this function does not wait.
put
is a special case of update in which initialValue
is value
and updator
is a function that ignores the input and returns value
.
name of the object to replace (could be a cell or an item of a pool)
sequence of array indexes, map keys, and record field names to dig down to before replacing
a tagged union (Scala Either
) of Left(exception object) or Right(new value at the end of the path)
Removes an item with a given name
.
Removes an item with a given name
.
Blocks during initialization and during any other update (put
, update
, or remove
). Blocking is at the granularity of a particular item: if another item (with another name
) is being updated, this function does not wait.
name of the object to replace (could be a cell or an item of a pool)
old value
Block updates and return a snapshot of the SharedMap
at a point in time.
Replaces or adds an item with a given name
at substructure path
with an updator
function (if it exists) or an initialValue
(if it does not), returning the new value if there are no errors or an exception otherwise.
Replaces or adds an item with a given name
at substructure path
with an updator
function (if it exists) or an initialValue
(if it does not), returning the new value if there are no errors or an exception otherwise.
Blocks during initialization and during any other update (put
, update
, or remove
). Blocking is at the granularity of a particular item: if another item (with another name
) is being updated, this function does not wait.
name of the object to replace (could be a cell or an item of a pool)
sequence of array indexes, map keys, and record field names to dig down to before replacing
value to use it the object does not yet exist
function to apply to an existing object to get a new value
a tagged union (Scala Either
) of Left(exception object) or Right(new value at the end of the path)
Methods like get
, put
, etc.
Methods like get
, put
, etc. should wait for initialize
to finish. Concrete implementations should call blockUntilInitialized
first to ensure that the SharedMap
is past the initialization stage.
The first time a SharedMap
is built, it may need to set up many names at once and ensure that all of these names are installed before any further access.
The first time a SharedMap
is built, it may need to set up many names at once and ensure that all of these names are installed before any further access. This function provides a way to do that.
initialize
only takes effect the first time it is called. After that, it is strictly pass-through.
An abstract class for shared memory whose update granularity is one item in the map.
Make subclasses of this class for sharing data in different circumstances, such as data shared among JVM processes or among compute nodes in a network, using databases, etc.
The
SharedState
/SharedMap
policy is:initialize
first, and all other methods block untilinitialize
is done.get
never blocks (afterinitialize
is done), returning whatever version of an item is available when it is called. (Aput
,update
, orremove
might be in progress, butget
does not wait for the new version.)put
replaces one item in the map with a prefabricated alternative, blocking if that item is being modified (put
,update
, orremove
) by another thread.put
does not block if other items in the map are being modified. If apath
is provided, theput
only changes a part of the item, but the whole item blocks.update
replaces one item in the map with anupdator
function, which transforms an old value into a new value. The same blocking rules apply as forput
, including apath
for modifying substructures. A prefabricatedinitialValue
must be provided in casename
does not yet exist in the map: theinitialValue
is inserted, rather than evaluating theupdator
function.remove
removes one item from the map, following the same blocking rules asput
.