Timing riddle

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Timing riddle

Stéphane Rollandin
[
        [5 seconds asDelay wait]
                valueWithin: 2 seconds onTimeout: []
]
durationToRun

--> 0:00:00:02.001
so far so good


[
        3 timesRepeat: [
                [5 seconds asDelay wait]
                        valueWithin: 2 seconds onTimeout: []]
]
durationToRun

--> 0:00:00:06.001
seems ok


[
        [
                [5 seconds asDelay wait]
                        valueWithin: 2 seconds onTimeout: []
        ]
        valueWithin: 3 seconds onTimeout: []
]
durationToRun

--> 0:00:00:02.001
alright


BUT:


[
        [
                3 timesRepeat: [
                        [5 seconds asDelay wait]
                                valueWithin: 2 seconds onTimeout: []]
        ]
        valueWithin: 3 seconds onTimeout: []
]
durationToRun

--> 0:00:00:05

?


Stef

Reply | Threaded
Open this post in threaded view
|

Re: Timing riddle

Nicolas Cellier
Look at implementation of #valueWithin:onTimeout:

It relies on signalling a TimeOut to activeProcess...
So it is not re-entrant :
- the first TimeOut is signalled by inner watchdog after 2 seconds.
- it is caught by inner valueWithin:onTimeout: wich starts the second
inner iteration
- the second TimeOut is signalled by inner watchdog after 3 seconds (1
second later)
- it is caught by inner valueWithin:onTimeout: wich starts the third
inner iteration
- the third TimeOut is signalled by inner watchdog 2 seconds later
(after 5 seconds)

Maybe #valueWithin:onTimeout: could be rewritten susing
Semaphore>>waitTimeoutMSecs:

Nicolas



2012/12/4 Stéphane Rollandin <[hidden email]>:

> [
>         [5 seconds asDelay wait]
>                 valueWithin: 2 seconds onTimeout: []
> ]
> durationToRun
>
> --> 0:00:00:02.001
> so far so good
>
>
> [
>         3 timesRepeat: [
>                 [5 seconds asDelay wait]
>                         valueWithin: 2 seconds onTimeout: []]
> ]
> durationToRun
>
> --> 0:00:00:06.001
> seems ok
>
>
> [
>         [
>                 [5 seconds asDelay wait]
>                         valueWithin: 2 seconds onTimeout: []
>         ]
>         valueWithin: 3 seconds onTimeout: []
> ]
> durationToRun
>
> --> 0:00:00:02.001
> alright
>
>
> BUT:
>
>
> [
>         [
>                 3 timesRepeat: [
>                         [5 seconds asDelay wait]
>                                 valueWithin: 2 seconds onTimeout: []]
>         ]
>         valueWithin: 3 seconds onTimeout: []
> ]
> durationToRun
>
> --> 0:00:00:05
>
> ?
>
>
> Stef
>

Reply | Threaded
Open this post in threaded view
|

Re: Timing riddle

Nicolas Cellier
2012/12/4 Nicolas Cellier <[hidden email]>:
> Look at implementation of #valueWithin:onTimeout:
>
> It relies on signalling a TimeOut to activeProcess...
> So it is not re-entrant :
> - the first TimeOut is signalled by inner watchdog after 2 seconds.
> - it is caught by inner valueWithin:onTimeout: wich starts the second
> inner iteration
> - the second TimeOut is signalled by inner watchdog after 3 seconds (1
> second later)

Err the second TimeOut is signalled by outer watchdog
(tourne ta langue sept fois dans ta bouche !)

> - it is caught by inner valueWithin:onTimeout: wich starts the third
> inner iteration
> - the third TimeOut is signalled by inner watchdog 2 seconds later
> (after 5 seconds)
>
> Maybe #valueWithin:onTimeout: could be rewritten susing
> Semaphore>>waitTimeoutMSecs:
>
> Nicolas
>
>
>
> 2012/12/4 Stéphane Rollandin <[hidden email]>:
>> [
>>         [5 seconds asDelay wait]
>>                 valueWithin: 2 seconds onTimeout: []
>> ]
>> durationToRun
>>
>> --> 0:00:00:02.001
>> so far so good
>>
>>
>> [
>>         3 timesRepeat: [
>>                 [5 seconds asDelay wait]
>>                         valueWithin: 2 seconds onTimeout: []]
>> ]
>> durationToRun
>>
>> --> 0:00:00:06.001
>> seems ok
>>
>>
>> [
>>         [
>>                 [5 seconds asDelay wait]
>>                         valueWithin: 2 seconds onTimeout: []
>>         ]
>>         valueWithin: 3 seconds onTimeout: []
>> ]
>> durationToRun
>>
>> --> 0:00:00:02.001
>> alright
>>
>>
>> BUT:
>>
>>
>> [
>>         [
>>                 3 timesRepeat: [
>>                         [5 seconds asDelay wait]
>>                                 valueWithin: 2 seconds onTimeout: []]
>>         ]
>>         valueWithin: 3 seconds onTimeout: []
>> ]
>> durationToRun
>>
>> --> 0:00:00:05
>>
>> ?
>>
>>
>> Stef
>>

Reply | Threaded
Open this post in threaded view
|

Re: Timing riddle

Andreas.Raab
In reply to this post by Stéphane Rollandin
Good catch! I took your examples and turned them into unit tests.
After that I posted a fixed version of valueWithin:onTimeout: to the trunk :-)

Cheers,
  - Andreas

Stéphane Rollandin wrote
[
        [5 seconds asDelay wait]
                valueWithin: 2 seconds onTimeout: []
]
durationToRun

--> 0:00:00:02.001
so far so good


[
        3 timesRepeat: [
                [5 seconds asDelay wait]
                        valueWithin: 2 seconds onTimeout: []]
]
durationToRun

--> 0:00:00:06.001
seems ok


[
        [
                [5 seconds asDelay wait]
                        valueWithin: 2 seconds onTimeout: []
        ]
        valueWithin: 3 seconds onTimeout: []
]
durationToRun

--> 0:00:00:02.001
alright


BUT:


[
        [
                3 timesRepeat: [
                        [5 seconds asDelay wait]
                                valueWithin: 2 seconds onTimeout: []]
        ]
        valueWithin: 3 seconds onTimeout: []
]
durationToRun

--> 0:00:00:05

?


Stef
Reply | Threaded
Open this post in threaded view
|

Re: Timing riddle

David T. Lewis
On Tue, Dec 04, 2012 at 11:42:09AM -0800, Andreas.Raab wrote:
> Good catch! I took your examples and turned them into unit tests.
> After that I posted a fixed version of valueWithin:onTimeout: to the trunk
> :-)
>

In case no one mentioned it ... this is great. Thanks!

Dave


Reply | Threaded
Open this post in threaded view
|

Re: Timing riddle

Nicolas Cellier
For me it's a demonstration of great efficiency of trunk process, 1
reporter, 1 analyst, 1 commiter in short loop....
Unless it only was a demonstration of efficiency of Andreas ;)

Nicolas

2012/12/6 David T. Lewis <[hidden email]>:

> On Tue, Dec 04, 2012 at 11:42:09AM -0800, Andreas.Raab wrote:
>> Good catch! I took your examples and turned them into unit tests.
>> After that I posted a fixed version of valueWithin:onTimeout: to the trunk
>> :-)
>>
>
> In case no one mentioned it ... this is great. Thanks!
>
> Dave
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Timing riddle

Andreas.Raab
Nicolas Cellier wrote
For me it's a demonstration of great efficiency of trunk process, 1
reporter, 1 analyst, 1 commiter in short loop....
Unless it only was a demonstration of efficiency of Andreas ;)
It wasn't. I saw your post and thought, gee, this ought to be easy to fix :-)

Cheers,
  - Andreas