Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!purdue!lerc.nasa.gov!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!Germany.EU.net!Frankfurt.Germany.EU.net!news.maz.net!ins.net!heeg.de!uucp
From: Hans-Martin Mosner <hmm@heeg.de>
Subject: Re: "timingOut in smalltalk sockets ..SOS"
Content-Type: text/plain; charset=us-ascii
Message-ID: <31171E7F.15FB7483@heeg.de>
Sender: uucp@heeg.de
Content-Transfer-Encoding: 7bit
Organization: Georg Heeg Objektorientierte Systeme
References: <4f2d2i$mkf@serv-200.dfki.uni-kl.de> <4f2muc$63n@usenet4.interramp.com>
Mime-Version: 1.0
Date: Tue, 6 Feb 1996 09:25:19 GMT
X-Mailer: Mozilla 2.0b5 (X11; I; SunOS 4.1.3 sun4c)
Lines: 39

Faisal Waris wrote:
> Essentially, something like the following is required:
> 
> | proc |
> TimeoutSignal handle: [:ex | socket close].
> do:[
> ..
> proc := [(Delay forSeconds: 10) wait. TimeoutSignal raise] fork.
> ..
> proc terminate.
> socket close].
> 
Exactly this will not work, as raising a signal looks for a handler
in the current process. Since the delay process is forked, raising
the signal in it can not cause the handler block in the other process
to run.
This is better: (I did not test it, though)

| proc1 proc2 |
proc1 := Processor activeProcess.
TimeoutSignale handle: [:ex | socket close]
do:[
..
proc2 := [(Delay forSeconds: 10) wait.
	  proc1 interruptWith: [TimeoutSignal raise]] fork.
..
proc2 terminate.
socket close].

The interruptWith: makes sure that the block gets executed in the
process which has the exception handler.

Hans-Martin

-- 
+--- Hans-Martin Mosner -------- Senior Smalltalk Guru ---+
| These opinions are entirely ficticious.  Any similarity |
| to real opinions is purely coincidental and unintended. |
+--- <hmm@heeg.de> ------ URL:http://www.heeg.de/~hmm/ ---+
