[squeak-dev] Alternate BlockContext>>forkAt: for Andreas, was #fork and deterministic resumption of the resulting process

Gary Chambers gazzaguru2 at btinternet.com
Mon Mar 3 10:17:53 UTC 2008


Of course, #1 may never run the context if there is a process that only
tields and doesn't wait (via delay or semaphore)...

[[true] whileTrue: [Processor yield]] fork.
[(Processor waitingProcessesAt: Processor activeProcess priority) notEmpty]
whileTrue: [Processor
yield]. self inform: 'waiting ends'

:-)
Gary


>
> Lou
>
> "Suggestion 1 from Lou"
> BlockContext>>forkAt: priority
> 	"Create and schedule a Process running the code in the receiver
> 		at the given priority. Answer the newly created process."
> 	| forkedProcess helperBlock |
>
> 	helperBlock := [
> 		[(Processor waitingProcessesAt: priority) notEmpty]
> whileTrue: [Processor
> yield].
> 		self value.
> 	].
> 	forkedProcess := Process forContext: helperBlock priority:
> priority.
> 	^forkedProcess resume.
>
> >




More information about the Squeak-dev mailing list