pharo-contributions / taskit

TaskIt is a library that ease Process usage in Pharo. It provides abstractions to execute and synchronize concurrent tasks, and several pre-built mechanisms that are useful for many application developers.
MIT License
43 stars 24 forks source link

Worker pool exceeds size #36

Closed ce1ebrimbor closed 6 years ago

ce1ebrimbor commented 6 years ago

While executing this test, seldom it gives a positive result (The conditions are met to create the failure):

TKTCommonQueueWorkerPoolTests >>> testWorkerPoolDoesNotExceedPoolSizeWhenSchedulingTasksInParallel
    <expectedFailure>
    | pool totalTasks futures |
    pool := TKTCommonQueueWorkerPool new.
    pool poolMaxSize: 10.
    pool start.
    totalTasks := 0.
    futures := AtomicSharedQueue new.
    1 to: 10 do: [ :i | futures nextPut: (pool future: [ 10 timesRepeat: [ futures nextPut: (pool future: [ totalTasks := totalTasks + 1 ]) ] ]) ].
    [ futures isEmpty ] whileFalse: [ futures next waitForCompletion: 100 milliSeconds ].
    self assert: totalTasks equals: 100.
    self assert: pool size equals: 10

capture du 2018-03-16 16-32-32

I think there might be an issue linked to the time delays.

sbragagnolo commented 6 years ago

Hi Daniel!

Me my self i added that to finish the integration (since it was not a show stopper) I am working on making the addition of a new worker safe for mt.