Bert Freudenberg a écrit :
On Sat, 26 May 2007 14:12:59 +0200, Damien Cassou wrote:
Thank you for this comments. That was what I was afraid of. Is it possible to have test that will show #nextPutAll: is not protected?
I'm not convinced #nextPutAll: should be atomic. It would mean a consumer cannot start processing queued items before all elements are written. Right now, #nextPutAll: uses #nextPut: which is "protected". Nothing to fix IMHO.
The test to find out whether #nextPutAll: is atomic or not would be to have a higher-priority reader process that reads one element and peeks for the next. If that succeeds, the lower-priority writer process managed to put in more than one element, meaning #nextPutAll: is not atomic. With the current behavior, however, the reader process would be activated as soon as the first element was written and the peek would fail (I mean, answer nil).
- Bert -
I think Damien was trying to prove that nextPutAll: IS NOT atomic.
It can be pre-empted - if the process explicitely yield (not possible, there is not a yield call under nextPutAll:) - if the process is blocked on a Semaphore (could occur if write on external streams) - if a higher priority process is unblocked.
But i do not remember: would the Processor give hand to a process of same priority if none of above conditions happen? (based on round-robin or something).
If not, Damien will have to imagine more tricky code creating one of the 3 conditions above to demonstrate the feature.
Nicolas