equal
deleted
inserted
replaced
1 "{ Package: 'stx:goodies/xtreams/terminals/tests' }" |
|
2 |
|
3 "{ NameSpace: Xtreams }" |
|
4 |
|
5 InfiniteReadingWritingTests subclass:#SharedQueueReadingWritingTest |
|
6 instanceVariableNames:'queue' |
|
7 classVariableNames:'' |
|
8 poolDictionaries:'XtreamsPool' |
|
9 category:'Xtreams-Terminals-Tests' |
|
10 ! |
|
11 |
|
12 |
|
13 !SharedQueueReadingWritingTest methodsFor:'initialize-release'! |
|
14 |
|
15 setUp |
|
16 |
|
17 queue := SharedQueue new: 1024. |
|
18 (input := queue reading) contentsSpecies: ByteArray. |
|
19 (output := queue writing) contentsSpecies: ByteArray |
|
20 ! ! |
|
21 |
|
22 !SharedQueueReadingWritingTest methodsFor:'utilities'! |
|
23 |
|
24 timeout: timeoutDuration server: serverBlock client: clientBlock |
|
25 "For tests that must be able to write and read at the same time, where they may block on each. |
|
26 Sockets, Pipes have an operating system buffer which dictates its bandwidth." |
|
27 |
|
28 | timeout |
|
29 serverSuccess serverProcess serverLock |
|
30 clientSuccess clientProcess clientLock| |
|
31 |
|
32 timeout := false. |
|
33 serverLock := Semaphore new. |
|
34 clientLock := Semaphore new. |
|
35 serverSuccess := clientSuccess := false. |
|
36 serverProcess := [serverSuccess := serverBlock value. serverLock signal] fork. |
|
37 clientProcess := [clientSuccess := clientBlock value. clientLock signal] fork. |
|
38 |
|
39 serverLock wait. |
|
40 clientLock wait. |
|
41 |
|
42 self assert: serverSuccess. |
|
43 self assert: clientSuccess. |
|
44 self deny: timeout |
|
45 ! ! |
|
46 |
|
47 !SharedQueueReadingWritingTest class methodsFor:'documentation'! |
|
48 |
|
49 version_SVN |
|
50 ^ '$Id$' |
|
51 ! ! |
|