JNodeOS v1.1.5 API

edu.utah.janos.nodeos
Class CommSpaceHandle

java.lang.Object
  |
  +--edu.utah.janosvm.sys.ListNode
        |
        +--edu.utah.janosvm.sys.Importable
              |
              +--edu.utah.janos.nodeos.CommSpaceHandle

public final class CommSpaceHandle
extends edu.utah.janosvm.sys.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.
 
Method Summary
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.
 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
clone, equals, pointsTo
 
Methods inherited from class edu.utah.janosvm.sys.ListNode
append, prepend, remove
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommSpaceHandle

public CommSpaceHandle()
Create an empty handle.
See Also:
newCommSpace(CommSpaceHandle,int)
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.

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.

JNodeOS v1.1.5 API

This documentation is Copyright (C) 1998-2001 The University of Utah. All Rights Reserved. See the file LICENSE for distribution terms.
Documentation, software, and mailing list archives for Janos can be found at the Janos Project: http://www.cs.utah.edu/flux/janos/