Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: (Updated Again) Win32::MMF - Memory Mapped File Support for Perl

by xiper (Friar)
on Feb 16, 2004 at 01:58 UTC ( #329204=note: print w/replies, xml ) Need Help??


in reply to (Updated Again) Win32::MMF - Memory Mapped File Support for Perl

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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://329204]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2023-01-29 15:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?