JsonTupleSpace

io.github.cakelier.tuples.space.client.JsonTupleSpace
See theJsonTupleSpace companion object

A coordination medium to be used to exchange pieces of information and coordinate with other entities, implemented to be used with JsonTuples and JsonTemplates.

A "tuple space", in general, is what is called a coordination medium. It is a way to coordinate the entities that participate in its use. It is a way to exchange information, more specifically tuples and with this implementation JsonTuples, and to coordinate the different actions of the entities. For a "tuple space", the coordination happens with the same operations that let to write and to read into the space. The basic operations, "in" and "rd", have a suspensive semantic, which means that their completion suspends until a tuple able to complete them is found in the space. In this way, similarly to the "future" data structure, the execution can be paused until the result is ready. Matching a tuple means to have a template to be used by the operation for matching, which in this implementation is a JsonTemplate.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def close(): Future[Unit]

Closes the connection to the server. This operation is needed to correctly perform all clean up operations both in the client and in the server, to dispose of all resources used. It is fundamental to call this method, otherwise the closing of the application will lead to the server thinking that a disconnection occurred and it will retain all data about this client, littering its memory with not freed up resources. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete signalling only the success of the operation.

Closes the connection to the server. This operation is needed to correctly perform all clean up operations both in the client and in the server, to dispose of all resources used. It is fundamental to call this method, otherwise the closing of the application will lead to the server thinking that a disconnection occurred and it will retain all data about this client, littering its memory with not freed up resources. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete signalling only the success of the operation.

Attributes

Returns

a Future which completes when the completion of the closing operation has occurred

def in(tt: JsonTemplate): Future[JsonTuple]

The operation for taking a JsonTuple from this JsonTupleSpace. This is one of the core operations on the tuple space, along with "rd" and "out". This is a suspensive operation, it will complete only when in the space a tuple matching the template of this operation is found. This also mean that the operation will not suspend at all, if a tuple is already inside the space. If multiple tuples matching the template are inside the space, one will be chosen randomly, following the "don't care" nondeterminism. The tuple matched is then removed from the tuple space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete with the matched tuple.

The operation for taking a JsonTuple from this JsonTupleSpace. This is one of the core operations on the tuple space, along with "rd" and "out". This is a suspensive operation, it will complete only when in the space a tuple matching the template of this operation is found. This also mean that the operation will not suspend at all, if a tuple is already inside the space. If multiple tuples matching the template are inside the space, one will be chosen randomly, following the "don't care" nondeterminism. The tuple matched is then removed from the tuple space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete with the matched tuple.

Value parameters

tt

the JsonTemplate to be used for matching a JsonTuple to be taken in this JsonTupleSpace

Attributes

Returns

a Future which completes when the operation has completed with the taken JsonTuple

def inAll(tt: JsonTemplate): Future[Seq[JsonTuple]]

The operation for taking some JsonTuples from this JsonTupleSpace. This is the "bulk" version of the basic "in" operation. Differently from its basic counterpart, this is not a suspensive operation, if no tuples matching the given template are found, an empty Seq is returned. If multiple tuples matching the template are inside the space, all will be returned in a Seq. The tuples matched are removed from the tuple space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete with the matched tuples.

The operation for taking some JsonTuples from this JsonTupleSpace. This is the "bulk" version of the basic "in" operation. Differently from its basic counterpart, this is not a suspensive operation, if no tuples matching the given template are found, an empty Seq is returned. If multiple tuples matching the template are inside the space, all will be returned in a Seq. The tuples matched are removed from the tuple space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete with the matched tuples.

Value parameters

tt

the JsonTemplate to be used for matching some JsonTuples to be taken from this JsonTupleSpace

Attributes

Returns

a Future which completes when the operation has completed with the taken JsonTuples

def inp(tt: JsonTemplate): Future[Option[JsonTuple]]

The operation for taking a JsonTuple from this JsonTupleSpace. This is the "predicative" version of the basic "in" operation: this means that it's not a suspensive operation. If no tuples matching the given template are found, a None is returned. If multiple tuples matching the template are inside the space, one will be chosen randomly, following the "don't care" nondeterminism. The tuple matched is then removed from the tuple space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete with a Some containing the matched tuple, if any.

The operation for taking a JsonTuple from this JsonTupleSpace. This is the "predicative" version of the basic "in" operation: this means that it's not a suspensive operation. If no tuples matching the given template are found, a None is returned. If multiple tuples matching the template are inside the space, one will be chosen randomly, following the "don't care" nondeterminism. The tuple matched is then removed from the tuple space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete with a Some containing the matched tuple, if any.

Value parameters

tt

the JsonTemplate to be used for matching a JsonTuple to be taken from this JsonTupleSpace

Attributes

Returns

a Future which completes when the operation has completed with a Some containing the taken JsonTuple, if present, a None otherwise

def no(tt: JsonTemplate): Future[Unit]

The operation for checking if some JsonTuples are not into this JsonTupleSpace. This is a suspensive operation, it will complete only when in the space no tuple matching the template of this operation is found. This also mean that the operation will not suspend at all, if no tuple is already inside the space. If multiple tuples matching the template are inside the space, only when the last one is removed the operation will complete. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete signalling only the success of the operation.

The operation for checking if some JsonTuples are not into this JsonTupleSpace. This is a suspensive operation, it will complete only when in the space no tuple matching the template of this operation is found. This also mean that the operation will not suspend at all, if no tuple is already inside the space. If multiple tuples matching the template are inside the space, only when the last one is removed the operation will complete. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete signalling only the success of the operation.

Value parameters

tt

the JsonTemplate to be used for matching JsonTuples which should not be in this JsonTupleSpace

Attributes

Returns

a Future which completes when the operation has completed

def nop(tt: JsonTemplate): Future[Boolean]

The operation for checking if some JsonTuples are not into this JsonTupleSpace. This is the "predicative" version of the basic "no" operation: this means that it's not a suspensive operation. If no tuples matching the given template are found, true is returned, otherwise false is returned. The tuples matched are not removed from the tuple space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete with a boolean with the result of the operation.

The operation for checking if some JsonTuples are not into this JsonTupleSpace. This is the "predicative" version of the basic "no" operation: this means that it's not a suspensive operation. If no tuples matching the given template are found, true is returned, otherwise false is returned. The tuples matched are not removed from the tuple space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete with a boolean with the result of the operation.

Value parameters

tt

the JsonTemplate to be used for matching JsonTuples which should not be in this JsonTupleSpace

Attributes

Returns

a Future which completes when the operation has completed with the result of the operation

def out(t: JsonTuple): Future[Unit]

The operation for inserting a JsonTuple into this JsonTupleSpace. This is one of the core operations on the tuple space, along with "in" and "rd". Differently from these two, this operation is not suspensive: it completes right away, because it is always allowed to insert a new tuple into the space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete signalling only the success of the operation.

The operation for inserting a JsonTuple into this JsonTupleSpace. This is one of the core operations on the tuple space, along with "in" and "rd". Differently from these two, this operation is not suspensive: it completes right away, because it is always allowed to insert a new tuple into the space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete signalling only the success of the operation.

Value parameters

t

the JsonTuple to be inserted into this JsonTupleSpace

Attributes

Returns

a Future which completes when the operation has completed

def outAll(ts: JsonTuple*): Future[Unit]

The operation for inserting multiple JsonTuples into this JsonTupleSpace. This is the "bulk" version of the basic "out" operation. As for its basic counterpart, this operation is not suspensive: it completes right away, because it is always allowed to insert new tuples into the space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete signalling only the success of the operation.

The operation for inserting multiple JsonTuples into this JsonTupleSpace. This is the "bulk" version of the basic "out" operation. As for its basic counterpart, this operation is not suspensive: it completes right away, because it is always allowed to insert new tuples into the space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete signalling only the success of the operation.

Value parameters

ts

the JsonTuples to be inserted into this JsonTupleSpace

Attributes

Returns

a Future which completes when the operation has completed

def rd(tt: JsonTemplate): Future[JsonTuple]

The operation for reading a JsonTuple into this JsonTupleSpace. This is one of the core operations on the tuple space, along with "in" and "out". This is a suspensive operation, it will complete only when in the space a tuple matching the template of this operation is found. This also mean that the operation will not suspend at all, if a tuple is already inside the space. If multiple tuples matching the template are inside the space, one will be chosen randomly, following the "don't care" nondeterminism. The tuple matched is not removed from the tuple space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete with the matched tuple.

The operation for reading a JsonTuple into this JsonTupleSpace. This is one of the core operations on the tuple space, along with "in" and "out". This is a suspensive operation, it will complete only when in the space a tuple matching the template of this operation is found. This also mean that the operation will not suspend at all, if a tuple is already inside the space. If multiple tuples matching the template are inside the space, one will be chosen randomly, following the "don't care" nondeterminism. The tuple matched is not removed from the tuple space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete with the matched tuple.

Value parameters

tt

the JsonTemplate to be used for matching a JsonTuple to be read in this JsonTupleSpace

Attributes

Returns

a Future which completes when the operation has completed with the read JsonTuple

def rdAll(tt: JsonTemplate): Future[Seq[JsonTuple]]

The operation for reading some JsonTuples into this JsonTupleSpace. This is the "bulk" version of the basic "rd" operation. Differently from its basic counterpart, this is not a suspensive operation, if no tuples matching the given template are found, an empty Seq is returned. If multiple tuples matching the template are inside the space, all will be returned in a Seq. The tuples matched are not removed from the tuple space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete with the matched tuples.

The operation for reading some JsonTuples into this JsonTupleSpace. This is the "bulk" version of the basic "rd" operation. Differently from its basic counterpart, this is not a suspensive operation, if no tuples matching the given template are found, an empty Seq is returned. If multiple tuples matching the template are inside the space, all will be returned in a Seq. The tuples matched are not removed from the tuple space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete with the matched tuples.

Value parameters

tt

the JsonTemplate to be used for matching some JsonTuples to be read in this JsonTupleSpace

Attributes

Returns

a Future which completes when the operation has completed with the read JsonTuples

def rdp(tt: JsonTemplate): Future[Option[JsonTuple]]

The operation for reading a JsonTuple into this JsonTupleSpace. This is the "predicative" version of the basic "rd" operation: this means that it's not a suspensive operation. If no tuples matching the given template are found, a None is returned. If multiple tuples matching the template are inside the space, one will be chosen randomly, following the "don't care" nondeterminism. The tuple matched is not removed from the tuple space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete with a Some containing the matched tuple, if any.

The operation for reading a JsonTuple into this JsonTupleSpace. This is the "predicative" version of the basic "rd" operation: this means that it's not a suspensive operation. If no tuples matching the given template are found, a None is returned. If multiple tuples matching the template are inside the space, one will be chosen randomly, following the "don't care" nondeterminism. The tuple matched is not removed from the tuple space. A Future is still returned because the actual tuple space can be hosted on a remote host, meaning that the operation is in fact a network operation that takes time to complete. The future will complete with a Some containing the matched tuple, if any.

Value parameters

tt

the JsonTemplate to be used for matching a JsonTuple to be read in this JsonTupleSpace

Attributes

Returns

a Future which completes when the operation has completed with a Some containing the read JsonTuple, if present, a None otherwise