JanosVM v0.6.0 Java API

## edu.utah.janosvm.kit.comm.commspace
Class CommSpaceHandle

    java.lang.Object
      |
      +--edu.utah.janosvm.sys.ListNode
            |
            +--edu.utah.janosvm.sys.Importable
                  |
                  +--edu.utah.janosvm.kit.comm.commspace.CommSpaceHandle

public final class CommSpaceHandle
extends Importable

A handle on a CommSpace. A CommSpace is an inter-process communication facility based lightly on Linda's "tuples". The space consists of an array of CommSpaceElements. Elements are copied out on read. A thread may write, read, swap, "wait" or "take" any element.

XXX Semantics during a failed take() are probably wrong.

Author:
  Janos Ministry of Development
See Also:
  `CommSpace`

Fields inherited from class edu.utah.janosvm.sys.ListNode
`pred, succ`

Constructor Summary
`CommSpaceHandle()` Create an empty handle.
`CommSpaceHandle(CommSpaceHandle other)` Copy constructor.

Method Summary
`protected void` `bindTo(Exportable ex)` Bind this Importable to the given Exportable.
`static CommSpaceHandle` `newCommSpace(CommSpaceHandle csh, int size)` Create a CommSpace and attach it to the given handle.
`static CommSpaceHandle` `newCommSpace(int size)` Create a new CommSpace of the given size and return a handle to it.
`CommSpaceElement` `read(int index)` Read the element at the given index.
`int` `resize(int newsize)` Resize the CommSpace pointed to by this handle to contain the given number of slots.
`int` `size()` Return the number of slots in the CommSpace pointed to by this handle.
`CommSpaceElement` `swap(int index, CommSpaceElement elem)` Swap an element with the one currently in the given index.
`CommSpaceElement` `take(int index)` Take an element from the given index and put a null in its place.
`protected void` `unbindFrom()` Unbind this Importable from any objects its referencing.
`CommSpaceElement` `waitToTake(int index)` Wait for an element to be placed into the given index.
`void` `write(int index, CommSpaceElement elem)` Write the given element to the given index.

Methods inherited from class edu.utah.janosvm.sys.Importable
`copy, finalize, revoke, toString`

Methods inherited from class edu.utah.janosvm.sys.ListNode
`append, clone, prepend, remove`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### CommSpaceHandle

    public CommSpaceHandle()

  Create an empty handle.
  See Also:
    `newCommSpace(CommSpaceHandle,int)`

### CommSpaceHandle

    public CommSpaceHandle(CommSpaceHandle other)

  Copy constructor. Only used when passing a csh to a child flow.
  Parameters:
    `other` - The handle to copy.

Method Detail

### newCommSpace

    public static CommSpaceHandle newCommSpace(int size)

  Create a new CommSpace of the given size and return a handle to it.
  Parameters:
    `size` - The size of the CommSpace.
  Returns:
    The handle to the CommSpace.

### newCommSpace

    public static CommSpaceHandle newCommSpace(CommSpaceHandle csh,
                                               int size)

  Create a CommSpace and attach it to the given handle.
  Parameters:
    `csh` - The CommSpaceHandle to attach to the newly created CommSpace.
    `size` - The size of the CommSpace.
  Returns:
    The handle that was passed in.

### bindTo

    protected void bindTo(Exportable ex)

  Description copied from class: Importable
  Bind this Importable to the given Exportable. The most common implementation of this method would be to cast the Exportable to the type that the Importable subclass handles and store it in the object as well as any other handy pointers/values.
  Overrides:
    bindTo in class Importable
  Tags copied from class: Importable
  Parameters:
    `ex` - The Exportable that is being imported.

### unbindFrom

    protected void unbindFrom()

  Description copied from class: Importable
  Unbind this Importable from any objects its referencing. The most common implementation of this method would be null out any object references in this object.
  Overrides:
    unbindFrom in class Importable

### size

    public int size()

  Return the number of slots in the CommSpace pointed to by this handle.

### resize

    public int resize(int newsize)

  Resize the CommSpace pointed to by this handle to contain the given number of slots.

  XXX what happens when resizing to smaller than current and dropping items?

### write

    public void write(int index,
                      CommSpaceElement elem)
               throws java.lang.ArrayIndexOutOfBoundsException

  Write the given element to the given index. Overwrites whatever is already there.
  Parameters:
    `index` - The index in the CommSpace to write into.
    `elem` - The element to copy into the CommSpace.

### take

    public CommSpaceElement take(int index)
                          throws java.lang.ArrayIndexOutOfBoundsException

  Take an element from the given index and put a null in its place. The read and replace are atomic with respect to other take()s at the given index. XXX semantically equivalent to swap(index, null)
  Parameters:
    `index` - The index in the CommSpace that we should take.
  Returns:
    null or the CommSpaceElement that was in the given index.
  See Also:
    `swap(int,CommSpaceElement)`

### waitToTake

    public CommSpaceElement waitToTake(int index)
                                throws java.lang.InterruptedException,
                                       java.lang.ArrayIndexOutOfBoundsException

  Wait for an element to be placed into the given index. Then atomically take the element and replace with null.
  Parameters:
    `index` - The index in the CommSpace that we should take.
  Returns:
    the CommSpaceElement that was in the given index.

### read

    public CommSpaceElement read(int index)
                          throws java.lang.ArrayIndexOutOfBoundsException

  Read the element at the given index.
  Parameters:
    `index` - The index in the CommSpace that we should take.
  Returns:
    Null or the CommSpaceElement that was in the given index.

### swap

    public CommSpaceElement swap(int index,
                                 CommSpaceElement elem)
                          throws java.lang.ArrayIndexOutOfBoundsException

  Swap an element with the one currently in the given index.
  Parameters:
    `index` - The index in the CommSpace that we should take.
    `elem` - The element to swap into the index.
  Returns:
    Null or the CommSpaceElement that was in the given index.

JanosVM v0.6.0 Java API

This documentation is Copyright (C) 2000-2002 The University of Utah. All Rights Reserved. See the documentation license for distribution terms and restrictions.
Documentation, software, and mailing lists for the JanosVM can be found at the Janos Project web page: http://www.cs.utah.edu/flux/janos/
Generated on Mar 17, 2002