Copyright © (C) 2017, Fred Youhanaie
Authors: Fred Youhanaie (fyrlang@anydata.co.uk).
This module provides the client access to the user applications.
In order to run any espace based applications the application
needs to be started using one of the start/0,1
functions.
Multiple independent instances of espace
can be active within
the same node without interfering with each other. There can be up
to one unnamed instance, and as many named instance as desired.
Instance names are short atoms that are appended to the various
server and table names.
espace
, then the unnamed instance is assumed.
eval/1 | Perform an eval operation via the unnamed espace server. |
eval/2 | Perform an eval operation via a named espace server. |
in/1 |
Perform an in operation via the unnamed espace server. |
in/2 |
Perform an in operation via a named espace server. |
infile/1 | Read and process an espace input file via the unnamed server. |
infile/2 | Read and process an espace input file via a named server. |
inp/1 |
Perform an inp operation via the unnamed espace server. |
inp/2 |
Perform an inp operation via a named espace server. |
out/1 |
Perform an out operation via the unnamed espace server. |
out/2 |
Perform an out operation via a named espace server. |
rd/1 |
Perform a rd operation via the unnamed espace server. |
rd/2 |
Perform a rd operation via a named espace server. |
rdp/1 |
Perform a rdp operation via the unnamed espace server. |
rdp/2 |
Perform a rdp operation via a named espace server. |
start/0 | Start a new unnamed instance of espace. |
start/1 | Start a new named instance of espace. |
stop/0 | Stop the unnamed instance of espace. |
stop/1 | Stop a named instance of espace. |
worker/1 | start a new worker process via the unnamed espace server. |
worker/2 | start a new worker process via a named espace server. |
eval(Tuple::tuple()) -> pid()
Perform an eval
operation via the unnamed espace server.
eval/2
for details.
eval(Inst_name::atom(), Tuple::tuple()) -> pid()
Perform an eval
operation via a named espace server.
The input Tuple is evaluated in a worker process and the result is
sent to the tuple space using out
operation.
The function returns the pid of the worker process.
The elements of the output tuple correspond to those of
Tuple
. If any of the elements of Tuple
match the function
pattern, then the corresponding output element will be the value of
the function.
The following patterns will trigger the evaluation of the second element of the tuple:
{aa, fun () -> 2+3 end
, zz}.
{aa, {fun (X,Y) -> X+Y end, [2, 3]}, zz}
Both examples above will produce {aa, 5, zz}
In the first example we have a fun
expression of arity zero. In
the second, we have a pair (tuple) of a fun
expression and a
list
, and the arity of the fun
matches the length of the list.
in(Pattern::tuple()) -> {list(), tuple()} | quit
Perform an in
operation via the unnamed espace server.
in/2
for details.
in(Inst_name::atom(), Pattern::tuple()) -> {list(), tuple()} | quit
Perform an in
operation via a named espace server.
For details of possible patterns see the match_spec in
ets:match/2,3
. Pattern
must be a tuple. It may consist of
expressions, or it may contain $N
pattern variables, where N>0.
If the pattern does not match a tuple in the tuple space, then the
call will block until such a pattern is added to the tuple space.
If the espace server terminates while the client is in blocking
state the atom quit
will be returned.
If a match is found, the tuple is returned as a pair {List,
Tuple}
, where Tuple
is the whole tuple, and List
is a,
possibly empty, list containing the matched $N
pattern
variables. The items in the list will be ordered by the $N
variable numbers.
For example the tuple {add, 34, 88}
will match the pattern {add,
'$2', '$1'}, and the returned result will be '{[88, 34], {add, 34,
88}}'. Note the order of the numbers in the list.
infile(File::file:name_all()) -> ok
Read and process an espace input file via the unnamed server.
See infile/2 for details.infile(Inst_name::atom(), File::file:name_all()) -> ok
Read and process an espace input file via a named server.
The file should be a valid Erlang terms file.inp(Pattern::tuple()) -> nomatch | {list(), tuple()}
Perform an inp
operation via the unnamed espace server.
inp/2
for details.
inp(Inst_name::atom(), Pattern::tuple()) -> nomatch | {list(), tuple()}
Perform an inp
operation via a named espace server.
The inp/1,2
functions are the non-blocking versions of
in/1,2`. If a match is not found in the first instance, then the
atom `nomatch
is returned. If a match is found, then it will be
removed from the tuple space and returned as a {List, Tuple}
pair.
in/1,2
for details and examples of the match patterns.
out(Tuple::tuple()) -> done
Perform an out
operation via the unnamed espace server.
out/2
for details.
out(Inst_name::atom(), Tuple::tuple()) -> done
Perform an out
operation via a named espace server.
Tuple
supplied as argument will be added to the tuple
space. Duplicate tuples are allowed in the tuple space.
rd(Pattern::tuple()) -> {list(), tuple()} | quit
Perform a rd
operation via the unnamed espace server.
rd/2
for details.
rd(Inst_name::atom(), Pattern::tuple()) -> {list(), tuple()} | quit
Perform a rd
operation via a named espace server.
rd/1,2
functions behave in the same manner as in/1,2
except
that when a matching tuple is found, it will not be removed from
the tuple space.
rdp(Pattern::tuple()) -> nomatch | {list(), tuple()}
Perform a rdp
operation via the unnamed espace server.
rdp/2
for details.
rdp(Inst_name::atom(), Pattern::tuple()) -> nomatch | {list(), tuple()}
Perform a rdp
operation via a named espace server.
rdp/1,2
are the non-blocking versions of
rd/1,2
. That is, if a match is not found, then nomatch
is
returned, and if a match is found the matching tuple will be
return, but it will not be removed from the tuple space.
start() -> ok | {error, term()}
Start a new unnamed instance of espace.
start(Inst_name::atom()) -> ok | {error, term()}
Start a new named instance of espace.
stop() -> ok | {error, term()}
Stop the unnamed instance of espace.
stop(Inst_name::atom()) -> ok | {error, term()}
Stop a named instance of espace.
worker(MFA::tuple()) -> pid()
start a new worker process via the unnamed espace server.
Seeworker/2
for details.
worker(Inst_name::atom(), X2::tuple()) -> pid()
start a new worker process via a named espace server.
The function expects a single tuple as argument, which can have one of the following forms:
{Mod, Fun, Args}
triple, e.g. {adder1, test_add2, []}
.{fun () -> adder1:test_add2()
end}
, or {fun adder1:test_add2/0}
.{fun (A,B) ->
adder1:test_add2(A,B) end}
, or {fun adder1:test_add2/2,
[A,B]}
."fun () -> adder1:test_add2()
end."
. This is mainly for use in espace input files.Generated by EDoc