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;