Skip to content
Shane McLean edited this page Oct 13, 2017 · 7 revisions

This section will give a brief walkthrough on the basics of dotSpace. Follow the links (below, or to the right in the Overview) for a detailed overview of the classes.


Space

DotSpace supports three concrete implementations tuple space data structures:

Each of the above tuple space implementations offer the same operations and have similar behaviour. The only difference is the ordering of the tuple's within the data structure. All concrete implementations of tuple spaces support Put, Get, GetP, GetAll, Query, QueryP and QueryAll.


Example of creating a new space:

    SequentialSpace space = new SequentialSpace();

Tuple

The default Tuple class is a mutable container of values very much like an array. While the values within the tuple can be modified, the size is fixed once instantiated.


Example of using a declared tuple variable:

    Tuple t1 = new Tuple("myvalue1", 1234);
    space.Put(t1);

The codesnippet above illustrates how to declare and instantiate a new tuple, and then store it inside a tuple space.


Pattern

The Pattern class allows one to retrieve tuples from a given space by matching either values or types. Patterns can be declared either as variables or inline arguments of the respective space operation.


Example of pattern declarations:

    Pattern pattern1 = new Pattern(typeof(string),typeof(int));
    Pattern pattern2 = new Pattern("value1",1234);
    Pattern pattern3 = new Pattern(typeof(string),1234);

The above codesnippet illustrates how to declare patterns using either value or type bindings. As seen in the example, declaring a pattern is done by specifying a variable number of values or type definitions.


Example of using a declared pattern variable:

    Pattern pattern = new Pattern(typeof(string), typeof(int));
    Tuple t1 = space.Get(pattern);

The above code snippet illustrates how to use a declared pattern variable. Once Get completes, t1 will be assigned to a tuple containing a string and an int.


Example of using inline patterns:

    Tuple t1 = space.Get("value1",1234);
    Tuple t2 = space.Get(typeof(string),,typeof(int));
    Tuple t3 = space.Get(typeof(string),1234);

As seen from the above code snippet, the tuple's t1, t2, and t3 are assigned a value returned from the space's Get operation. The pattern used is inlined, opposed to a declared pattern variable. The inline method allows one to directly specify the pattern with a variable number of parameters.

Clone this wiki locally