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