A process doesn't always terminate, does it? For example, could it be
suspended and garbage collected?: ([Transcript show: 'hello'] forkAt: 30) name: 'test'; suspend. ObjectMemory garbageCollect. (Process allInstances select: [:p | p name = 'test']) inspect I suppose in your scenario the semaphores would keep the process from being gc'd in the above example, but my point is that we cannot be 100% sure the semaphores will eventually be signalled for every process, because not every process runs to completion. Are there other situations besides suspend/gc where a process would never terminate? Dave Georg Heeg wrote: > All, > > In the ObjectStudio 8 project we have developed a solution for a similar > task: In ObjectStudio 8 you can attach semaphore to a process which will be > signalled when the process terminates. > > AR 50827 describes the setup to hook into class Process and introduces a new > method called finalTerminate which calls primTerminate by default and is > used in ObjectStudio 8 to be overridden by triggering any termination > semaphore: > > finalTerminate > (self environment at: #terminationSemaphores > ifAbsent: [OrderedCollection new]) do: [:each | each > signal]. > ^self primTerminate > > Maybe we can use this discussion to generalize the ObjectStudio 8 solution > and to have it included directly in the base. I still hope that AR 50827 > will make it soon. > > Georg > > PS: This is the ObjectStudio 8 way to set up the semaphore (Method from > class Process: > > waitForThreadExitMilliseconds: aNumber > | sem coll result | > sem := Semaphore new. > coll := self environment at: #terminationSemaphores > ifAbsent: > [self environment at: #terminationSemaphores put: > OrderedCollection new]. > coll add: sem. > self isTerminated ifTrue: [^#Exit]. > result := (sem waitFor: aNumber) ifTrue: [#Exit] ifFalse: > [#Timeout]. > coll remove: sem. > ^result > ":Section Reference waitForThreadExitMilliseconds: aNumber > Description: Wait for the completion of this thread but no more than > specified number of milliseconds. nil means > indefinite > wait. > Assumptions: None. > Return Value: A symbol. > #Error -- error has occurred > #Exit -- thread has terminated > #Timeout -- wait has timed out > Receiver Modified: No. > :End" > > -----Ursprüngliche Nachricht----- > Von: [hidden email] [mailto:[hidden email]] > Gesendet: Freitag, 13. Oktober 2006 01:43 > An: [hidden email] > Cc: [hidden email]; [hidden email] > Betreff: Re: Terminate and #ensure: blocks [was: Re: How to be informed when > a process terminates] > > [...] > > |
In reply to this post by Terry Raymond
Wow; now this is just the kind of thing that demonstrates Smalltalk at
its most sublime... and terrifying. ----- Joerg Beekmann DeepCove Labs 4th floor 595 Howe Street Vancouver, BC, V6C 2T5 voice +1.604.689.0322 fax +1.604.689.0311 [hidden email] CONFIDENTIALITY NOTICE Unless otherwise indicated this email contains information that is private and confidential. If you have received it in error, please notify the sender and delete this message along with any attachments. > -----Original Message----- > From: Terry Raymond [mailto:[hidden email]] > Sent: October 12, 2006 5:36 PM > To: Joerg Beekmann; 'Dave Stevenson'; 'Alan Knight' > Cc: 'vwnc-list' > Subject: RE: How to be informed when a process terminates > > Joerg > > You could always change the send stack and insert a > context that notifies you that the process exited normally. > > Terry > > =========================================================== > Terry Raymond Smalltalk Professional Debug Package > Crafted Smalltalk > 80 Lazywood Ln. > Tiverton, RI 02878 > (401) 624-4517 [hidden email] > <http://www.craftedsmalltalk.com> > =========================================================== > |
Free forum by Nabble | Edit this page |