Tuple spaces is a coordination model for communication in parallel computing environments.
A tuple space is a place where processes can put, read, and take tuples, which are in turn just sequences of values. For example, ("job", 12, 1.23)
is a tuple made up of a string, an integer, and a floating-point number; a tuple space can contain zero or more copies of that tuple, or of tuples containing other types of values, simple or complex.
A process puts something in tuple space with put(a, b, c, ...)
, take something out with take(a, b, c, ...)
, or copy something leaving the original in tuple space with copy(a, b, c, ...)
. The arguments to take
and copy
are either actual values, or variables with specific types; values match themselves, while types match things of that type. For example:
put("job", 12, 1.23)
puts the tuple ("job", 12, 1.23) in the tuple space- if f is a floating point variable,
take("job", 12, ?f)
takes that tuple out of tuple space, assigning 1.23 to f - but
take("job", 15, ?f)
blocks, because there is no tuple in tuple space matching the pattern (12 doesn't match 15) - and if i is an integer variable,
copy("job", ?i, ?f)
assigns 12 to i and 1.23 to f, but leaves the tuple in tuple space.
There are non-blocking versions of take
and copy
called try_take
and try_copy
that either match right away and return true, assigning values to variables in their patterns, or fail to match, don't do any assignment, and return false.
Summary
put
: Puts a tuple into the tuplespacetake
: Takes out a tuple that matches a given pattern from the tuplespace (if there's no match, the operation is blocked)copy
: Copies a tuple that matches a given pattern from the tuplespace (if there's no match, the operation is blocked)try_take
: A non-blocking version ofin
(if there's no match, an error message is returned)try_copy
: A non-blocking version ofrd
(if there's no match, an error message is returned)