Package org.jspace

Interface Space

All Known Implementing Classes:
PileSpace, QueueSpace, RandomSpace, RemoteSpace, SequentialSpace, StackSpace

public interface Space
A space is a concurrent data structure that can be used to coordinate activities of threads. Each space is a collection of tuples. These are sequences of values. Each space provides operations that can be used to add, read and remove tuples from the space. Tuples are retrieved/selected from the tuple space via pattern matching.
  • Method Summary

    Modifier and Type Method Description
    java.lang.Object[] get​(TemplateField... fields)
    Retrieves (and remove) a tuple matching the requested template.
    java.util.List<java.lang.Object[]> getAll​(TemplateField... fields)
    Retrieves (and remove) all the tuples matching a template.
    java.lang.Object[] getp​(TemplateField... fields)
    Retrieves (and remove) a tuple matching the requested template.
    boolean put​(java.lang.Object... fields)
    Adds a tuple in the space.
    java.lang.Object[] query​(TemplateField... fields)
    Reads (without removing) a tuple matching the requested template.
    java.util.List<java.lang.Object[]> queryAll​(TemplateField... fields)
    Reads (without removing) all the tuples matching the requested template.
    java.lang.Object[] queryp​(TemplateField... fields)
    Reads (without removing) a tuple matching the requested template.
    int size()
    Returns the number of tuples that are stored in the space.
  • Method Details

    • size

      int size()
      Returns the number of tuples that are stored in the space.
    • put

      boolean put​(java.lang.Object... fields) throws java.lang.InterruptedException
      Adds a tuple in the space.
      Parameters:
      fields - fields of inserted tuple
      Returns:
      true if the action has been successfully executed false otherwise.
      Throws:
      java.lang.InterruptedException - if any thread interrupted the current thread before the action is executed.
    • get

      java.lang.Object[] get​(TemplateField... fields) throws java.lang.InterruptedException
      Retrieves (and remove) a tuple matching the requested template. A template is rendered as an array of TemplateField. The returned, say result will satisfy the following properties:
      • result.length==fields.length;
      • for any i, fields[i].match(return[i])==true.
      Current thread is suspended until a tuple matching the requested template is found.
      Parameters:
      fields - an array of template fields representing the requested template
      Returns:
      a tuple matching the requested template
      Throws:
      java.lang.InterruptedException - if any thread interrupted the current thread before the action is executed.
    • getp

      java.lang.Object[] getp​(TemplateField... fields) throws java.lang.InterruptedException
      Retrieves (and remove) a tuple matching the requested template. A template is rendered as an array of TemplateField. The returned, say result will satisfy the following properties:
      • result.length==fields.length;
      • for any i, fields[i].match(return[i])==true.
      If a tuple matching the requested tempalte is not found, null is returned.
      Parameters:
      fields - an array of template fields representing a template
      Returns:
      a tuple matching the template or null if no tuple matches the template
      Throws:
      java.lang.InterruptedException - if any thread interrupted the current thread before the action is executed.
    • getAll

      java.util.List<java.lang.Object[]> getAll​(TemplateField... fields) throws java.lang.InterruptedException
      Retrieves (and remove) all the tuples matching a template. If no matching tuple is found, the empty list is returned.
      Parameters:
      fields - an array of template fields representing a template
      Returns:
      a list containing all the tuples matching the template
      Throws:
      java.lang.InterruptedException - if any thread interrupted the current thread before the action is executed.
    • query

      java.lang.Object[] query​(TemplateField... fields) throws java.lang.InterruptedException
      Reads (without removing) a tuple matching the requested template. A template is rendered as an array of TemplateField. The returned, say result will satisfy the following properties:
      • result.length==fields.length;
      • for any i, fields[i].match(return[i])==true.
      Current thread is suspended until a tuple matching the requested template is found.
      Parameters:
      fields - an array of template fields representing the requested template
      Returns:
      a tuple matching the requested template
      Throws:
      java.lang.InterruptedException - if any thread interrupted the current thread before the action is executed.
    • queryp

      java.lang.Object[] queryp​(TemplateField... fields) throws java.lang.InterruptedException
      Reads (without removing) a tuple matching the requested template. A template is rendered as an array of TemplateField. The returned, say result will satisfy the following properties:
      • result.length==fields.length;
      • for any i, fields[i].match(return[i])==true.
      Value null is returned if no matching tuple is found.
      Parameters:
      fields - an array of template fields representing the requested template
      Returns:
      a list containing all the tuples matching the template
      Throws:
      java.lang.InterruptedException - if any thread interrupted the current thread before the action is executed.
    • queryAll

      java.util.List<java.lang.Object[]> queryAll​(TemplateField... fields) throws java.lang.InterruptedException
      Reads (without removing) all the tuples matching the requested template. A template is rendered as an array of TemplateField. The returned, say result will satisfy the following properties:
      • result.length==fields.length;
      • for any i, fields[i].match(return[i])==true.
      Parameters:
      fields - an array of template fields representing the requested template
      Returns:
      a list containing all the tuples matching the template
      Throws:
      java.lang.InterruptedException - if any thread interrupted the current thread before the action is executed.