View Source espace_tspatt_srv (espace v0.9.0)
Custodian for the espace_tspatt
, waiting patterns, ETS table.
The table is created as an ordered_set
and in protected
mode. All access to the table is expected to come through this server. However, other proceses can inspect its contents for debugging purposes.
The table keeps track of client processes that are blocked on in
or rd
waiting for a tuple matching their pattern to be added to the tuple space. In effect the ETS table is a pattern waiting list.
Our sole client is espace_tspace_srv
. Whenever an in
or rd
operation does not find a match the client is given a unique key to wait on, and that key along with the pattern and client's pid is passed to us, via add_pattern/4
, to add to the waiting list.
Whenever a new tuple is added to the tuple space, we will receive a copy of the tuple, via check_waitlist/2
, to check against waiting patterns. If we find a match, the correponding client(s) will be notified of the new arrival.
Communication from espace_tspace_srv
is unidirectional. Once it sends us a request, it will continue with its own work. We never reply to espace_tspace_srv
.
The ETS table name used will reflect the espace
instance name. This will be espace_tspatt
for the default/unnamed instance, and espace_tspatt_abc
for an instance named abc
.
etsmgr
application is used to add resilience to the server data, should the server restart while it is holding tuple patterns.
Summary
Functions
Add a new pattern to the waiting list.
Check a tuple against waiting patterns.
Starts the server
Functions
Add a new pattern to the waiting list.
We insert thePattern
along with the client's pid and unique ref in the ETS table.
Check a tuple against waiting patterns.
We check the newly added tuple against the existing client patterns using ets:test_ms/2
. If a pattern is found, the waiting client(s) will be informed, via their Pid
and Cli_Ref
, to retry the in
or rd
operation.
Starts the server
We expect an instance name to be supplied, which will be used to uniquely identify the ETS table for the instance.