Not sure if this is specific to Win32::MMF::Shareable (v0.07), but when you $mw->waitVariable( \$tied_var ) while using Tk, it doesn't resume when $tied_var is updated in another process.
Like so:
use strict;
use Tk;
use Win32::MMF::Shareable;
my $wait;
tie( $wait, 'Win32::MMF::Shareable', 'wait' );
$wait = 0;
my $pid;
unless( $pid = fork )
{
$SIG{HUP} = \&stop;
while( 1 ) { sleep 1 }
}
my $mw = MainWindow->new;
$mw->Button( -text => '$wait', -command => sub { pri
+nt "\$wait is $wait\n" } )->pack;
$mw->Button( -text => 'waitVariable( \\$wait )', -command => \&start )
+->pack;
$mw->Button( -text => 'local $wait++', -command => \&stop )
+->pack;
$mw->Button( -text => 'remote $wait++', -command => sub{ kill
+( 'HUP', $pid ) } )->pack;
MainLoop;
kill( 'TERM', $pid );
sub start
{
print "waiting for \$wait (was $wait)\n";
$mw->waitVariable( \$wait );
print "finished waiting for \$wait (is now $wait)\n";
}
sub stop
{
print "\$wait++ by pid $$\n";
$wait++;
}
__END__
# [\d] is button pressed
$wait is 0 # [1] start on 0
waiting for $wait (was 0) # [2] start waiting
$wait++ by pid 2372 # [3] increment locally
finished waiting for $wait (is now 1) # ... all okay
waiting for $wait (was 1) # [2] wait again
$wait++ by pid -2184 # [4] increment remotely
# ... nothing happens
$wait is 2 # [1] but it has been increment
+ed
$wait++ by pid 2372 # [3] increment locally again
finished waiting for $wait (is now 3) # ... and it works
- ><iper
use japh; print;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|