1015
|
1 |
"{ Package: 'stx:libbasic2' }"
|
|
2 |
|
|
3 |
Stream subclass:#InternalPipeStream
|
|
4 |
instanceVariableNames:'queue'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Streams'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!InternalPipeStream class methodsFor:'instance creation'!
|
|
12 |
|
|
13 |
new
|
|
14 |
^ self basicNew initialize
|
|
15 |
! !
|
|
16 |
|
|
17 |
!InternalPipeStream methodsFor:'accessing'!
|
|
18 |
|
|
19 |
atEnd
|
|
20 |
^ false . "/ queue notNil
|
|
21 |
!
|
|
22 |
|
|
23 |
close
|
|
24 |
queue := nil
|
|
25 |
!
|
|
26 |
|
|
27 |
next
|
|
28 |
"return the next element from the stream (might block until something is written)"
|
|
29 |
|
|
30 |
^ queue next
|
|
31 |
!
|
|
32 |
|
|
33 |
nextAvailableBytes:nMax into:aBuffer startingAt:startIndex
|
|
34 |
|n idx ch|
|
|
35 |
|
|
36 |
n := 0.
|
|
37 |
idx := startIndex.
|
|
38 |
[n <= nMax] whileTrue:[
|
|
39 |
ch := queue nextIfEmpty:[^ n ].
|
|
40 |
aBuffer at:idx put:ch.
|
|
41 |
idx := idx + 1.
|
|
42 |
n := n + 1
|
|
43 |
].
|
|
44 |
^ n
|
|
45 |
!
|
|
46 |
|
|
47 |
nextPut:something
|
|
48 |
"write an element (might wakeup readers)"
|
|
49 |
|
|
50 |
queue nextPut:something
|
|
51 |
! !
|
|
52 |
|
|
53 |
!InternalPipeStream methodsFor:'initialization'!
|
|
54 |
|
|
55 |
initialize
|
|
56 |
queue := SharedQueue new.
|
|
57 |
! !
|
|
58 |
|
|
59 |
!InternalPipeStream methodsFor:'synchronization'!
|
|
60 |
|
|
61 |
readWait
|
|
62 |
queue readSemaphore wait
|
|
63 |
! !
|
|
64 |
|
|
65 |
!InternalPipeStream class methodsFor:'documentation'!
|
|
66 |
|
|
67 |
version
|
|
68 |
^ '$Header: /cvs/stx/stx/libbasic2/InternalPipeStream.st,v 1.1 2002-02-11 09:32:54 cg Exp $'
|
|
69 |
! !
|