The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Unblocking an Exit

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Unblocking an Exit Posted: Dec 13, 2006 10:30 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Unblocking an Exit
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Travis Griggs - Blog

Advertisement

Michaell's been having some fun with context stitching. Cool stuff. One of the things I bugged him to look at didn't quite turn out all the way though. A while ago, there was a thread on one of the Smalltalk mailing lists about telling when a process is done, from another process. And I proposed a similiar technique as what Michaell has used for his onExitDo:. Bascically, walk backwards along the processes context chain until you get near the beginning, and then insert hooks to do whatever you want. It was a good post, and I feel a bit like Ellen Feis not being able to locate it.

Either way, both approaches have a problem. Consider the following naive example:

countDown := 
		[10 to: 1
			by: -1
			do: 
				[:n | 
				n out.
				(Delay untilSeconds: Time secondClock + 1) wait].
		'Lift Off!' out] 
				fork.
#('Michaell' 'Travis' 'Terry' 'David') 
	do: [:each | countDown onExitDo: [(each , ' applauds.') out]]
It won't work. It'll UHE. Why? I mean besides the fact that I used those #out messages which are in my image, but not yours (load Out from the Open Repository, it so unclutters Transcript spewing code). If we modify the code slighlty:
...
				fork.
Processor yield.
#('Michaell' 'Travis' 'Terry' 'David')
...
now it will work. The problem is that in my naive example, the countDown process has never come alive yet when I'm registering the exit blocks. So it has no context chain to analyze and restitch with hooks to do our exit actions. Luckily, Smalltalks awesome introspection abilities aren't limited just to context objects. BlockClosure are equaly extensible and introspectable. Basically, the version of BeforeYouLeave just published does just that. It peeks inside the block that will eventually be run. Said block is the process execution machinery, and it has a reference to the block you gave it to run. So we just replace that reference with a new block, one that runs the original and ensures the exit condition. And this of course can be done repeatedly, and they restitching of the blocks copied values just nests nicely.

Read: Unblocking an Exit

Topic: Agile finances? Previous Topic   Next Topic Topic: IE7: Redmond, we have a problem

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use