Thread-Safe FileStreams
Mark Guzdial
guzdial at cc.gatech.edu
Mon Apr 6 19:53:15 UTC 1998
>I've tried it from Squeak - the result is the same. However, "/dev/stdout"
>is not considered to be a "regular" file. If you do the same with a usual
>file handle, only the second write should show the effect. That is at
>least what Squeak is doing if I try
I tried Andreas' example under MacOS, and it worked just fine. So, why
does the below generate primitive fail errors? -- two of them, one on each
close.
| aFile aFile1 aFile2 |
"Put something in the file"
aFile _ FileStream fileNamed: 'jack.test'.
1 to: 100 do: [:i | aFile nextPutAll: (i printString); cr.].
aFile close.
"Dual read test"
[ Transcript show: 'Proc1: Open-'.
aFile1 _ FileStream fileNamed: 'jack.test'.
(Delay forMilliseconds: (100 to: 500) atRandom) wait.
aFile1 contentsOfEntireFile.
(Delay forMilliseconds: (100 to: 500) atRandom) wait.
Transcript show: 'Proc1: Close-'.
aFile1 close.] fork.
[ Transcript show: 'Proc2: Open-'.
aFile2 _ FileStream fileNamed: 'jack.test'.
(Delay forMilliseconds: (100 to: 500) atRandom) wait.
aFile2 contentsOfEntireFile.
(Delay forMilliseconds: (100 to: 500) atRandom) wait.
Transcript show: 'Proc2: Close-'.
aFile2 close.] fork.
Is it just because there are two processes accessing the same file?
Mark
--------------------------
Mark Guzdial : Georgia Tech : College of Computing : Atlanta, GA 30332-0280
(404) 894-5618 : Fax (404) 894-0673 : guzdial at cc.gatech.edu
http://www.cc.gatech.edu/gvu/people/Faculty/Mark.Guzdial.html
More information about the Squeak-dev
mailing list
|