CSP for Java
(JCSP) 1.1-rc4

org.jcsp.plugNplay
Class Or

java.lang.Object
  extended by org.jcsp.plugNplay.Or
All Implemented Interfaces:
CSProcess

public final class Or
extends Object
implements CSProcess

Bitwise ors two Integer streams to one stream.

Process Diagram

    in0  ____
   -->--|    | out
    in1 | Or |-->--
   -->--|____|
 

Description

The Or class is a process which has an infinite loop that waits a Object of type Number to be sent down each of the in1 and in2 Channels. The process then calculates the bitwise OR on the intValue() of the two Numbers then write the result as a new Integer down the out Channel.

Channel Protocols

Input Channels
in1,in2 java.lang.Number Both Channels can accept data from any subclass of Number. It is possible to send Floats down one channel and Integers down the other. However all values will be converted to ints.
Output Channels
out java.lang.Integer The output will always be of type Integer.

Example

The following example shows how to use the Or process in a small program. The program also uses some of the other building block processes. The program generates a sequence of numbers and rounds each even number up to the nearest odd number and prints this on the screen.
 import org.jcsp.lang.*;
 import org.jcsp.plugNplay.*;
 
 public class OrExample {
 
   public static void main (String[] argv) {
 
     final One2OneChannel a = Channel.one2one ();
     final One2OneChannel b = Channel.one2one ();
     final One2OneChannel c = Channel.one2one ();
     final One2OneChannel d = Channel.one2one ();
 
     new Parallel (
       new CSProcess[] {
         new Numbers (a.out ()),
         new Generate (b.out (), 1),
         new Or (a.in (), b.in (), c.out ()),
         new Successor (c.in (), d.out ()),
         new Printer (d.in (), "--> ", "\n")
       }
     ).run ();
 
   }
 
 }
 

Author:
P.H. Welch and P.D. Austin

Constructor Summary
Or(ChannelInput in1, ChannelInput in2, ChannelOutput out)
          Construct a new Or process with the input Channels in1 and in2 and the output Channel out.
 
Method Summary
 void run()
          The main body of this process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Or

public Or(ChannelInput in1,
          ChannelInput in2,
          ChannelOutput out)
Construct a new Or process with the input Channels in1 and in2 and the output Channel out. The ordering of the Channels in1 and in2 make no difference to the functionality of this process.

Parameters:
in1 - the first input Channel
in2 - the second input Channel
out - the output Channel
Method Detail

run

public void run()
The main body of this process.

Specified by:
run in interface CSProcess

CSP for Java
(JCSP) 1.1-rc4

Submit a bug or feature to jcsp-team@kent.ac.uk
Version 1.1-rc4 of the JCSP API Specification (Copyright 1997-2008 P.D.Austin and P.H.Welch - All Rights Reserved)
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.