-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathJavaCspChannel.java
More file actions
133 lines (115 loc) · 2.73 KB
/
Copy pathJavaCspChannel.java
File metadata and controls
133 lines (115 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package JyCSP;
import org.python.core.*;
import JyCSP.Interfaces.JyCspChannelInterface;
import JyCSP.util.CspFactory;
/**
*
* @author Sam Wilson, Sarah Mount
* @version 1.0
*
* Java representation of the Jython Class Channel.
*
* CSP Channel objects.
* In csp there are two sorts of channel. In CSP terms these
* are Any2Any, Alting channels. However, each channel creates an
* operating system level pipe. Since this is a file object the
* number of channels a program can create is limited to the maximum
* number of files the operating system allows to be open at any one
* time. To avoid this bottleneck use L{FileChannel} objects, which
* close the file descriptor used for IPC after every read or write
* operations. Read and write operations are, however, over 20 time
* lower when performed on L{FileChannel} objects.
*
*
*/
public class JavaCspChannel extends PyObject implements JyCspChannelInterface{
/**
* Java Channel Interface for the Jython Class Channel.
*/
protected JyCspChannelInterface jcsi;
/**
* Name of the channel
*/
public String name;
/**
* Default Constructor
*
* Makes a call to the static method createJavaCspChannel in the
* CspFactory
*/
public JavaCspChannel(){
super();
this.jcsi = CspFactory.createJavaCspChannel();
}
/**
* Straight through call to Channel.write()
*
* Writes an object to the Channel
*
* Channel.write uses the Serializer Class. if an object is to be
* serialized correctly ensure that your class implements serializable
*/
public void write(Object o){
this.jcsi.write(o);
}
/**
* Straight through call to Channel.read()
*
* Reads the object stored in the channel
*
* The Type of the object written to teh channel is preserved,
* A type cast is required.
*/
public Object read(){
return this.jcsi.read();
}
/**
* Straight through call to Channel.poison()
*
* Poisons the channel
*/
public void poison(){
this.jcsi.poison();
}
/**
* Straight through call to Channel.select()
*
* Completes a channel read
*
* @return the object written to the channel
*/
public Object select(){
return this.jcsi.select();
}
/**
* Straight through call to Channel.disable()
*
* Disables this channel for alting
*
*/
public void disable(){
this.jcsi.disable();
}
/**
* Straight through call to Channel.enable()
*
* Enables this channel for alting
*/
public void enable(){
this.jcsi.enable();
}
/**
* Unknown behaviour
*/
public boolean is_selected(){
return this.jcsi.is_selected();
}
/**
* Straight through call to Channel.is_selectable()
*
* @return if the channel is selectable
*/
public boolean is_selectable(){
return this.jcsi.is_selectable();
}
}