author | Martin Kobetic |
Sun, 17 Nov 2013 00:23:18 -0500 | |
changeset 147 | bd6be28aa924 |
parent 109 | 9587e2df7029 |
permissions | -rw-r--r-- |
9 | 1 |
"{ Package: 'stx:goodies/xtreams/terminals' }" |
2 |
||
3 |
"{ NameSpace: Xtreams }" |
|
4 |
||
5 |
WriteStream subclass:#SharedQueueWriteStream |
|
6 |
instanceVariableNames:'contentsSpecies' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
25
02e7c3b6f63c
added XtreamsPool to fix DefaultBufferSize; set proper category names
mkobetic
parents:
9
diff
changeset
|
9 |
category:'Xtreams-Terminals' |
9 | 10 |
! |
11 |
||
12 |
SharedQueueWriteStream comment:'Write stream on a SharedQueue. Primarily used for data transfer between processes. |
|
13 |
{{{ |
|
14 |
queue := SharedQueue new. |
|
15 |
in := queue reading. |
|
16 |
out := queue writing. |
|
17 |
received := Array new writing. |
|
18 |
done := Semaphore new. |
|
109 | 19 |
consumer := |
9 | 20 |
[ | size | |
109 | 21 |
[ (size := in get) isZero |
9 | 22 |
] whileFalse: [ | word | |
23 |
word := ByteString new: size. |
|
24 |
in read: size into: word. |
|
25 |
received put: word ]. |
|
26 |
done signal. |
|
27 |
] fork. |
|
28 |
#(one two three four) do: [ :word | out put: word size; write: word ]. |
|
29 |
out put: 0. |
|
30 |
done wait. |
|
31 |
received conclusion |
|
32 |
}}} |
|
33 |
||
34 |
Instance Variables |
|
109 | 35 |
contentsSpecies <Class> species for collections of elements of this stream |
9 | 36 |
|
37 |
' |
|
38 |
! |
|
39 |
||
40 |
||
41 |
!SharedQueueWriteStream methodsFor:'accessing'! |
|
42 |
||
43 |
write: anInteger from: aSequenceableCollection at: startIndex |
|
44 |
startIndex to: startIndex + anInteger - 1 do: [:index | destination nextPut: (aSequenceableCollection at: index)]. |
|
45 |
^anInteger |
|
46 |
! ! |
|
47 |
||
48 |
!SharedQueueWriteStream methodsFor:'initialize-release'! |
|
49 |
||
50 |
close |
|
51 |
! |
|
52 |
||
53 |
contentsSpecies |
|
54 |
^contentsSpecies |
|
55 |
! |
|
56 |
||
57 |
contentsSpecies: aClass |
|
58 |
contentsSpecies := aClass |
|
59 |
! |
|
60 |
||
61 |
flush |
|
62 |
! |
|
63 |
||
64 |
on: aDestination |
|
65 |
super on: aDestination. |
|
66 |
contentsSpecies := Array |
|
67 |
! ! |
|
68 |
||
69 |
!SharedQueueWriteStream class methodsFor:'documentation'! |
|
70 |
||
109 | 71 |
version_HG |
72 |
||
73 |
^ '$Changeset: <not expanded> $' |
|
9 | 74 |
! ! |
109 | 75 |