Multiple processes using #nextPutAll:

Damien Cassou damien.cassou at gmail.com
Fri May 25 16:30:42 UTC 2007


Hi,

I've implemented a SharedQueue on top of Nile which protects against
concurrent access. However, #nextPutAll: is not protected and I would
like a test that shows it's not.

My current test pass but it should not.

testUsingNextPutAll
  "This test should not pass. Unfortunately, I'm not skilled enough in
processes management to make this test fail. In fact, since
#nextPutAll: is not protected, numbers should not be sorted the way
they are at the end.'"
  |queue writingBlock|
  queue := self newQueue.
  writingBlock := [queue nextPutAll: (1 to: 10000)].
  writingBlock
    fork;
    fork;
    fork.
  Processor yield.
  self assert: (queue next: 10000) asArray = (1 to: 10000) asArray.
  self assert: (queue next: 10000) asArray = (1 to: 10000) asArray.
  self assert: (queue next: 10000) asArray = (1 to: 10000) asArray.
  self assert: queue atEnd.


I assume it's because when I fork, the work is done before the
following fork starts.

Can somebody help me writing this test?

-- 
Damien Cassou



More information about the Squeak-dev mailing list