-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathCChannel.py
More file actions
78 lines (61 loc) · 1.62 KB
/
Copy pathCChannel.py
File metadata and controls
78 lines (61 loc) · 1.62 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
from csp.cspprocess import Guard
import Channel as chnl
import cPickle
import uuid
DEBUG = False
class CChannel(Guard):
def __init__(self):
Guard.__init__(self)
p = uuid.uuid4().int & 0xffffff
av = uuid.uuid4().int & 0xffffff
tak = uuid.uuid4().int & 0xffffff
shm = uuid.uuid4().int & 0xffffff
self.channel = chnl.getChannel(p, av, tak, shm)
return
def put(self,item):
a = cPickle.dumps(item)
chnl.put(self.channel,a)
return
def get(self):
ret = None
chnl.get(self.channel, ret)
item = cPickle.loads(ret)
if DEBUG: print item
return item
def is_selectable(self):
a = chnl.is_selectable(self.channel)
if a == 1:
return True
else:
return False
return
def write(self,item):
a = cPickle.dumps(item)
chnl._write(self.channel,a,len(a))
return
def read(self):
ret = chnl._read(self.channel)
if DEBUG: print ret
item = cPickle.loads(ret)
if DEBUG: print item
return item
def enable(self):
chnl.enable(self.channel)
return
def disable(self):
chnl.disable(self.channel)
return
def select(self):
ret = chnl._select(self.channel)
item = cPickle.loads(ret)
if DEBUG: print item
return item
def poison(self):
chnl.poison(self.channel);
return
def getStatus(self):
chnl.getStatus(self.channel)
return
def checkpoison(self):
chnl.checkpoison()
return