author | Martin Kobetic |
Sun, 17 Nov 2013 00:22:31 -0500 | |
changeset 144 | e193a6772be4 |
parent 109 | 9587e2df7029 |
permissions | -rw-r--r-- |
9 | 1 |
"{ Package: 'stx:goodies/xtreams/terminals' }" |
2 |
||
3 |
"{ NameSpace: Xtreams }" |
|
4 |
||
5 |
WriteStream subclass:#ExternalWriteStream |
|
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 |
ExternalWriteStream comment:'Used to write to BlockableIOAccessors (e.g sockets or pipes). This is a binary stream (consumes bytes/ByteArrays). |
|
13 |
||
14 |
{{{ |
|
15 |
[ :in :out | |
|
109 | 16 |
[ out writing write: ''Hello''; close. |
9 | 17 |
in reading read: 5 |
18 |
] ensure: [ in close. out close ] |
|
19 |
] valueWithArguments: SocketAccessor openPair |
|
20 |
}}} |
|
21 |
{{{ |
|
22 |
[ :in :out | |
|
109 | 23 |
[ out writing write: ''Hello''; close. |
9 | 24 |
in reading read: 5 |
25 |
] ensure: [ in close. out close ] |
|
26 |
] valueWithArguments: OSSystemSupport concreteClass pipeAccessorClass openPair |
|
27 |
}}} |
|
28 |
||
29 |
Instance Variables |
|
109 | 30 |
contentsSpecies <Class> species for collections of elements of this stream |
9 | 31 |
|
32 |
' |
|
33 |
! |
|
34 |
||
35 |
||
36 |
!ExternalWriteStream methodsFor:'accessing'! |
|
37 |
||
38 |
write: anInteger from: aSequenceableCollection at: startIndex |
|
109 | 39 |
| count wrote | |
40 |
anInteger isZero ifTrue: [^0]. |
|
41 |
count := 0. |
|
42 |
[count < anInteger] whileTrue: |
|
43 |
[wrote := destination nextPutBytes: anInteger - count from: aSequenceableCollection startingAt: startIndex + count. |
|
44 |
wrote isZero ifTrue: [(Incomplete on: aSequenceableCollection count: count at: startIndex) raise]. |
|
45 |
count := count + wrote]. |
|
46 |
^anInteger |
|
9 | 47 |
! ! |
48 |
||
49 |
!ExternalWriteStream methodsFor:'initialize-release'! |
|
50 |
||
51 |
close |
|
52 |
destination isActive ifFalse: [^self]. |
|
53 |
destination close |
|
54 |
! |
|
55 |
||
56 |
contentsSpecies |
|
57 |
^contentsSpecies |
|
58 |
! |
|
59 |
||
60 |
contentsSpecies: aClass |
|
61 |
contentsSpecies := aClass |
|
62 |
! |
|
63 |
||
64 |
on: anAccessor |
|
65 |
super on: anAccessor. |
|
66 |
contentsSpecies := ByteArray |
|
67 |
! ! |
|
68 |
||
69 |
!ExternalWriteStream class methodsFor:'documentation'! |
|
70 |
||
109 | 71 |
version_HG |
72 |
||
73 |
^ '$Changeset: <not expanded> $' |
|
9 | 74 |
! ! |
109 | 75 |