jist.runtime
Class Channel

java.lang.Object
  extended by jist.runtime.Entity.Empty
      extended by jist.runtime.Channel
All Implemented Interfaces:
Entity, JistAPI.Entity, JistAPI.Timeless, Timeless

public class Channel
extends Entity.Empty
implements JistAPI.Entity

Implements a single-slot channel ala Communicating Sequential Processes (CSP) by Hoare. Other synchronization primitives can be built atop this structure, or directly using the same idea. This Channel implementation may not block the sender, and may drop excessive sends by setting flags accordingly.

Since:
JIST1.0
Version:
$Id: Channel.java,v 1.16 2004/04/06 16:07:43 barr Exp $
Author:
Rimon Barr <barr+jist@cs.cornell.edu>

Nested Class Summary
 
Nested classes/interfaces inherited from interface jist.runtime.Entity
Entity.Empty, Entity.Static
 
Field Summary
static java.lang.reflect.Method _jistMethodStub_receive_28_29Ljava_2elang_2eObject_3b
          Jist method stub for receive method.
static java.lang.reflect.Method _jistMethodStub_send_28Ljava_2elang_2eObject_3b_29V
          Jist method stub for send(Object) method.
static java.lang.reflect.Method _jistMethodStub_send_28Ljava_2elang_2eObject_3bZZ_29V
          Jist method stub for send(Object) method.
static java.lang.reflect.Method _jistMethodStub_sendNonBlock_28Ljava_2elang_2eObject_3b_29V
          Jist method stub for sendNonBlock(Object).
static java.lang.reflect.Method _jistMethodStub_sendNonBlock_28Ljava_2elang_2eObject_3bZZ_29V
          Jist method stub for sendNonBlock(Object, boolean).
private  Event blockedReceiver
          Continuation event of blocked receiver.
private  Event blockedSender
          Continuation event of blocked sender.
private  java.lang.Object data
          Single data object passed through channel.
private  boolean hasData
          Whether channel is holding data.
 
Fields inherited from class jist.runtime.Entity.Empty
_jistField__ref
 
Constructor Summary
Channel()
          Create new Channel.
 
Method Summary
private  java.lang.Object clearData()
          Clear data from the channel.
 java.lang.Object receive()
          Blocking receive call.
 void send(java.lang.Object data)
          Blocking non-dropping send call.
 void send(java.lang.Object data, boolean shouldDropIfFull, boolean shouldDropIfNoReceiveWaiting)
          Blocking send call.
private  void send(java.lang.Object data, boolean shouldDropIfFull, boolean shouldDropIfNotReceiveWaiting, boolean shouldBlockSender)
          Blocking send call implementation.
 void sendNonBlock(java.lang.Object data)
          Non-blocking non-dropping send call.
 void sendNonBlock(java.lang.Object data, boolean shouldDropIfFull, boolean shouldDropIfNoReceiveWaiting)
          Non-blocking send call.
private  void setData(java.lang.Object data)
          Put data in the channel.
 
Methods inherited from class jist.runtime.Entity.Empty
_jistMethod_Get__ref, _jistMethod_Set__ref
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_jistMethodStub_receive_28_29Ljava_2elang_2eObject_3b

public static java.lang.reflect.Method _jistMethodStub_receive_28_29Ljava_2elang_2eObject_3b
Jist method stub for receive method.


_jistMethodStub_send_28Ljava_2elang_2eObject_3b_29V

public static java.lang.reflect.Method _jistMethodStub_send_28Ljava_2elang_2eObject_3b_29V
Jist method stub for send(Object) method.


_jistMethodStub_send_28Ljava_2elang_2eObject_3bZZ_29V

public static java.lang.reflect.Method _jistMethodStub_send_28Ljava_2elang_2eObject_3bZZ_29V
Jist method stub for send(Object) method.


_jistMethodStub_sendNonBlock_28Ljava_2elang_2eObject_3b_29V

public static java.lang.reflect.Method _jistMethodStub_sendNonBlock_28Ljava_2elang_2eObject_3b_29V
Jist method stub for sendNonBlock(Object).


_jistMethodStub_sendNonBlock_28Ljava_2elang_2eObject_3bZZ_29V

public static java.lang.reflect.Method _jistMethodStub_sendNonBlock_28Ljava_2elang_2eObject_3bZZ_29V
Jist method stub for sendNonBlock(Object, boolean).


blockedSender

private Event blockedSender
Continuation event of blocked sender.


blockedReceiver

private Event blockedReceiver
Continuation event of blocked receiver.


data

private java.lang.Object data
Single data object passed through channel.


hasData

private boolean hasData
Whether channel is holding data.

Constructor Detail

Channel

Channel()
Create new Channel.

See Also:
JistAPI
Method Detail

send

private void send(java.lang.Object data,
                  boolean shouldDropIfFull,
                  boolean shouldDropIfNotReceiveWaiting,
                  boolean shouldBlockSender)
Blocking send call implementation.

Parameters:
data - object to transmit
shouldDropIfFull - whether over-sent channel should throw exception or silently drop
shouldDropIfNotReceiveWaiting - whether send should be dropped if no receive is waiting
shouldBlockSender - whether sender should be blocked

send

public void send(java.lang.Object data,
                 boolean shouldDropIfFull,
                 boolean shouldDropIfNoReceiveWaiting)
          throws JistAPI.Continuation
Blocking send call.

Parameters:
data - object to transmit
shouldDropIfFull - whether over-sent channel should throw exception or silently drop
shouldDropIfNoReceiveWaiting - whether send should be dropped if no receive is waiting
Throws:
JistAPI.Continuation - never (merely a rewriter tag)

send

public void send(java.lang.Object data)
          throws JistAPI.Continuation
Blocking non-dropping send call.

Parameters:
data - object to transmit
Throws:
JistAPI.Continuation - never (merely a rewriter tag)

sendNonBlock

public void sendNonBlock(java.lang.Object data,
                         boolean shouldDropIfFull,
                         boolean shouldDropIfNoReceiveWaiting)
Non-blocking send call.

Parameters:
data - object to transmit
shouldDropIfFull - whether over-sent channel should throw exception or silently drop
shouldDropIfNoReceiveWaiting - whether send should be dropped if no receive is waiting

sendNonBlock

public void sendNonBlock(java.lang.Object data)
Non-blocking non-dropping send call.

Parameters:
data - object to transmit

receive

public java.lang.Object receive()
                         throws JistAPI.Continuation
Blocking receive call.

Returns:
transmitted data
Throws:
JistAPI.Continuation - never (merely a rewriter tag)

setData

private void setData(java.lang.Object data)
Put data in the channel.

Parameters:
data - data to insert into the channel

clearData

private java.lang.Object clearData()
Clear data from the channel.

Returns:
data in the channel, if any.