dispatchMessage: aMessage
...
semaphore wait.
result become: self
^super dispatchMessage: aMessage
This implementation waits for a signal in the semaphore and then turns itself into the result of the operation. This allows one to write code like this
| f |
f := Future promising: [2.0 + 2.0].
f printString.
The execution of the message sent to the Future will block in the #dispatchMessage: until the result of 2.0 + 2.0 is available and then send the printString to the result. There is only one downside, most smalltalk dialects don't have a dispatchMessage: like this.
No comments:
Post a Comment