[Goodie] asynchronous messaging

Rob Withers rwithers12 at mediaone.net
Mon Aug 27 07:13:41 UTC 2001


depends on Events, Tasks, Futures, and DispatchQueues

This starts to get interesting.  Please look at the class comment of the
AsyncObject for some examples. Have you transcript open when you run some of
them.

It works as follows.  There is a Secretary object  which owns a
DispatchQueue.  There is a #GlobalSecretary in the Smalltalk dictionary for
most objects.  Only those that override #secretary, to return their own
background secretaries, will run in the background.

Any object can be sent the asend message, to create an asynchronous sending
context.  This has a Trampoline referencing a AsyncMessageGenerator on the
receiver.  The Trampoline is a proxy with #doesNotUnderstand: redirection to
the generator.   The generator will ask the sender's secretary for a future.
(This is a special future with knows that it is to submit the
result/exception to the senders queue, so responses can be routed to the
right secretary).  We then submit the message and future to the receivers
secretary.  The message is evaluated in the Task of the receivers secretary,
then the future is evaluated with the result.  This cause an
asyncTriggerEvent to occur in the senders secretary, thus the response will
activate in the master process for that object (note: that you can fork and
have async messages sent from a process which is not the master process for
that sender).

NOTE:  This DOES NOT use the delegation framework, yet.  (The delegation
framework has it's own special VM).


enjoy!

- Rob

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Kernel-Async.1.cs
Type: application/octet-stream
Size: 20721 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20010827/823346c4/Kernel-Async.1.obj


More information about the Squeak-dev mailing list