N:S:M doesn't have a hook function inside the loop. If it did I could just set a timer using Time::HiRes to send a SIGALRM which I think would break out of the select() call that the process is blocked on and let a hook function run. After the hook the flow would move around to the select() again.
Well I do have the source for N:S:M so... I just overrode the loop() function in my own program with a
copy of the function by just changing the following bit of code from
$mux->loop(sub {
my ($rdready, $wrready) = @_;
&check_sigs();
$mux->endloop if $prop->{_HUP};
});
to
$mux->loop(sub {
my ($rdready, $wrready) = @_;
&check_sigs();
$self->inner_loop_hook; # user customizable hook
$mux->endloop if $prop->{_HUP};
});
All I did was add the line:
$self->inner_loop_hook; # user customizable hook
And then I just defined my own hook function as:
sub inner_loop_hook {
print "Dude! " , time , "\n";
}
I haven't tested any of this with Spread yet which will take a while yet. Also I setup a timer with these lines at the top of the program.
use Time::HiRes qw( setitimer getitimer
ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF );
setitimer(ITIMER_REAL, 3, 1);
$SIG{ALRM} = sub { return };
Which will wait 3 seconds before starting and then send a SIGALRM every 1 second after that.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.