On Monday, August 25, 2014 7:55:50 AM UTC-5, Edward K. Ream wrote:
>
> [A recent rev] contains a spectacular collapse in complexity in idle-time 
> handling.
>

Rev 2d1b80b...contains a necessary improvement. The previous examples 
worked only because references to IdleTime instances appeared at the module 
level.

The IdleTime ctor now appends a reference to self to the new 
g.app.idle_timers list.  This ensures that IdleTimer's do not get garbage 
collected prematurely. For example, the following handler now works.  It 
queues up two new handlers::

    def handler(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace(it.count,it.c.shortFileName(),'%2.4f' % (delta_t))
        if count == 3:
            # Start two more handlers.
            it1 = g.IdleTime(c,handler1,delay=500)
            it2 = g.IdleTime(c,handler2,delay=1000)
            if it1 and it2:
                it1.start()
                it2.start()
        if it.count >= 8:
            g.trace('done')
            it.stop()
            it.destroy_self()

And here is the result::

    handler 1 ekr.leo 0.5150
    handler 2 ekr.leo 1.0300
    handler 3 ekr.leo 1.5450
    handler 4 ekr.leo 2.0600
    handler1  1 ekr.leo 0.5150
    handler2  1 ekr.leo 1.0140
    handler1  2 ekr.leo 1.0290
    handler 5 ekr.leo 2.5740
    handler 6 ekr.leo 3.0890
    handler1  3 ekr.leo 1.5440
    handler2  2 ekr.leo 2.0280
    handler1  4 ekr.leo 2.0590
    handler 7 ekr.leo 3.6040
    handler 8 ekr.leo 4.1190
    handler done
    handler1  5 ekr.leo 2.5740
    handler1 done
    handler2  3 ekr.leo 3.0420
    handler2  4 ekr.leo 4.0570
    handler2  5 ekr.leo 5.0710
    handler2  6 ekr.leo 6.0850
    handler2  7 ekr.leo 7.0990
    handler2  8 ekr.leo 8.1130
    handler2  9 ekr.leo 9.1270
    handler2 10 ekr.leo 10.1410
    handler2 done

EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to