Tom Pollard wrote:

> On Thu, 25 Aug 2005, ajpeck wrote:
> 
>>Is there a way to forcibly terminate a thread after a specified time 
>>regardless if the thread is finished executing. 
> 
> 
> The standard eval{}-timeout technique apparently works well for threads.
> That is, wrap the code that might hang for 5 min in an eval{} block and
> use an alarm to time it out, e.g.
> 
> eval {
>   local %SIG{ALRM} = { die "TIMEOUT\n"; };
>   alarm 5;
>   <...your code here...>
>   alarm 0;
> }
> giveup() if $@ =~ /^TIMEOUT/;
> 
> ...where giveup() does whatver you need to do to exit from the thread 
> prematurely.  In general, threads and signals are awkward to use together, 
> but this particular idiom has been unproblematic for us in our threaded 
> perl apps.

win32 doesn't have signals and any that are implemented don't actually
interrupt the receiving process.  I believe they just use simple message
passing to fake it - so your mileage may vary.

-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to