help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Timeouts for BlockClosures


From: Holger Hans Peter Freyther
Subject: Re: [Help-smalltalk] Timeouts for BlockClosures
Date: Wed, 06 Apr 2011 10:56:33 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.9

On 04/06/2011 08:45 AM, Paolo Bonzini wrote:
> Almost there indeed, thanks for clarifying!
> 
> First comment: please move the TimeoutNotification under the Kernel namespace.
> 
>> +BlockClosure extend [
>> +    timeout: seconds do: aBlock [
> 
> So what do you think about passing a delay here?  Or even making this method
> Delay>>#value:onTimeout:?  Do you know what other Smalltalks do?

I am not sure. So far I have only seen individual timeouts for socket
operations. I am going to browse the Pharo code and see if there are some
constructs for timeout handling. I would like to be able to either pass a
Delay (for subseconds) or the seconds as Number. Maybe have two selectors and
make the one with a Number create the delay?



> 
>> +<category: '*timeout-private'>
>> +    "I will execute myself for up to seconds and if a timeout
>> +    occurs I will invoke the aBlock. If the timeout occurs early
>> +    not much of the block is executed yet. I also have some issues
>> +    with Delays and not breaking these properly.
> 
> Is the comment still accurate?

No, I will update it.



>> +    ]
>> +]
> 
>> +            ] timeout: 1 do: [events add: 'timeout'].
> 
> Larger timeout, please (1s for example).

The number is treated as a second already. The result will make sure that the
internal blocks has been executed, on a slow system the 1s might be too low.

will send an updated patch later today
        holger



reply via email to

[Prev in Thread] Current Thread [Next in Thread]