sacco has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to run the 'repeat' command in concurrent
events while spitting the output?
It seems like the repeat command pauses when you
start another repeat event, and resumes when stopped.

example:
sub whatever { . . $counter{$idx} = $time{$idx}->repeat(1000 => sub { $timev{$idx} = sprintf("%s",ctm($start_time{$idx})); }); }

Replies are listed 'Best First'.
Re: concurrent repeat events
by eserte (Deacon) on Apr 02, 2004 at 09:28 UTC
    It's not clear to me what your problem is. There's no problem in running concurrent repeat execution "threads":

    use Tk; $mw=tkinit; for my $i (1..10) { $mw->repeat(rand(900)+100, sub { warn "I'm $i.\n" }); } MainLoop;

    (At least this works on Linux).

    However the repeat callback blocks while it is executed. If you want real threads, then you have to use real threads, or fork a process. But note that you must not call any Tk-related functions while executing the thread --- Perl/Tk is not yet thread-safe.

Re: concurrent repeat events
by simonm (Vicar) on Apr 01, 2004 at 23:24 UTC
    You'll need to tell us more about the package you're using... What module provides the repeat() method?
      I'm using Perl 5.8 on an Windows platform.
      Tk provides a lightweight timer mechanism that can call
      back a procedure after a specified delay (specified
      in milliseconds) - the 'repeat' function.

      I'm trying to track different tasks with timers.
      I want to run concurrent timers, but it seems that
      when I try to run more than one 'repeat' function,
      only one runs, while the others are paused. I haven't
      seen any documentation that says it works for more
      than one.