On 2013-11-21, at 15:56, Yuriy Tymchuk <[email protected]> wrote:

> 
> On 20 Nov 2013, at 20:58, Clément Bera <[email protected]> wrote:
> 
>> So what you are looking for is Process and semaphores. 
>> 
>> This is not multithreading in the default Pharo VM + image, currently our 
>> semaphore/process management is not multithreaded, but executes all the 
>> process in the same thread. What happens basically is that you will run 
>> several processes in 1 thread with different priorities, and processes with 
>> highest priorities will be executed first. This is very good for your case, 
>> because if you put your task in another process with lower priority than the 
>> UI process, each time you will trigger a UI interaction the secondary 
>> process will be temporarily stopped to execute your UI interaction.
>> 
>> (see #forkAt: Process userBackgroundPriority)
> 
> One more thing: how do I synchronise? For example I want two async processes, 
> but when they both finish I want to execute something. Eg. return merged data 
> generated by processes.

Semaphores are your friends:

semaphore := Semaphore new.

[ ... First Job ...
        semaphore signal. ] fork.

[ ... Second Job ...
        semaphore signal. ] fork.

"consume to signals, aka. pause this thread until both jobs have finished"
semaphore wait; wait. 

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to