Process status

Mike Klein mike at twinsun.com
Fri Jul 10 22:19:46 UTC 1998



On Fri, 10 Jul 1998, Alexander Lazarevic wrote:

> Hi!
> 
> How do i ckeck that a process has finished?

If a Process is not the active process, the process's suspendedContext
being nil should indicate that the process is terminated.

However, rather than polling for completion, you should use a Semaphore.

For example: (modification of you code)


 | shepherd completionIndicator |
 completionIndicator := Semaphore new.
 shepherd := [1000 atRandom timesRepeat: [Transcript show: 'Sheep'; cr].
              completionIndicator signal.
              Processor yield] newProcess.
 shepherd resume.
 "Herd complete?"
 completionIndicator wait. "This line doesn't busy wait, unlike the line
below"
 "shepherd running whileTrue: [Delay forSeconds: 1]."


If the shepard process get's terminated without running to completion,
the semaphore will never get signaled, though.

Does Squeak have unwind/ensure blocks?

> ------  Alexander  Lazarevic  ------------------------------------------------

Cheers,
   Mike Klein





More information about the Squeak-dev mailing list