If I just had two threads to signal I would create a queue for each one and just enqueue the messages when I felt the need. the thread can then block on a queue read and do nothing until it gets a message

Updated to mention threads->create

... use Thread::Queue; my $conn_q = thread::queue->new() my $rev_q = thread::queue->new() sub connection_check { while (my $msg = $conn_q->dequeue) { # will block 'til it gets sign +aled # Do something } } ... # in main $conn_thread = threads->create('connection_check'); $conn_q->enqueue("Get on with it");

$min % 55 will be zero at 55 and at 0 minutes. Perhaps two timers would do your trick

my %timer = ( check_conn => 0, check_rev => 0, }; my %interval = ( check_conn => 5, # check conn every 5 min check_rev => 55, # and revocation at 55min }; while (1) { my $now = time; if ($now + interval{check_conn} * 60 > $timmer{check_conn} ) { #pa +ssed mark $timer{check_conn} = $now + interval{check_conn} * 60; # signal conn thread to do its work $conn_q->enqueue("Get on with it"); } # similar for check rev list # sleep 10; # or 60, or 300... }

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

In reply to Re: How do I queue perl subroutines to a thread queue instead of data? by Random_Walk
in thread How do I queue perl subroutines to a thread queue instead of data? by static0verdrive

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.