I'm using Win32::MMF::Shareable 0.9 under ActiveState Perl 5.8.3, and the documented ability to select the namespace at 'tie' time does not appear to work. Is this a bug in Win32:MMF or am I somehow barking up the wrong tree?
In short, when using the following syntax:
use Win32::MMF::Shareable; my $Var2; tie $Var2, "Win32::MMF::Shareable", "Var2", { namespace => 'test' };
The namespace will be "shareable" (the default namespace), not "test". This appears to contradict the "Description" section of Win32::MMF::Shareable, which states:
Note that if you try to tie a variable without specifying the namespace, the default namespace 'shareable' will be used. If you want to change how the default namespace is created, provide the namespace, swapfile and size options when you tie the first variable.
use Win32::MMF::Shareable; tie $scalar, "Win32::MMF::Shareable", "var_1", { namespace = 'MyNamespace', size = 1024 * 1024, swapfile = 'C:\private.swp' };
I have thrown together simple example programs that demonstrate this (read more below). Can anyone find anything I'm doing wrong? Alternately, does anyone know what the OO-interface equivalent of "push @tiedMMFvariable, $var;" would be, since choosing a namespace after "use" time seems to work better with OO?
Here are two "master" programs and three "client" programs:
If I run shared_master_use.pl in one window:
C:\ctl\mmf>shared_master_use.pl Var2 is "Kenneth, what's my namespace?" sleeps for 5 minutes to hold Var2 in memory...
Then I run the client programs:
C:\ctl\mmf>shared_client_use.pl Var2 is "Kenneth, what's my namespace?" C:\ctl\mmf>shared_client_tie.pl Var2 is "" C:\ctl\mmf>shared_client_use_shareable.pl Var2 is ""
Thus we see that, when we specify namespace at 'use' time, it is set to what we specify and not the default 'shareable'. Now let's run the other master program, which specifies namespace at 'tie' time:
C:\ctl\mmf>shared_master_tie.pl Var2 is "Kenneth, what's my namespace?" sleeps for 5 minutes to hold Var2 in memory...
and I get the opposite results from my clients:
C:\ctl\mmf>shared_client_use.pl Var2 is "" C:\ctl\mmf>shared_client_tie.pl Var2 is "Kenneth, what's my namespace?" C:\ctl\mmf>shared_client_use_shareable.pl Var2 is "Kenneth, what's my namespace?"
Here's the code to the various programs:
shared_master_use.pl#!perl use Win32::MMF::Shareable { namespace => 'test' }; my $Var2; tie $Var2, "Win32::MMF::Shareable", "Var2"; $Var2 = "Kenneth, what's my namespace?"; print "Var2 is \"$Var2\"\n"; sleep 300;
#!perl use Win32::MMF::Shareable; my $Var2; tie $Var2, "Win32::MMF::Shareable", "Var2", { namespace => 'test' }; $Var2 = "Kenneth, what's my namespace?"; print "Var2 is \"$Var2\"\n"; sleep 300;
#!perl use Win32::MMF::Shareable {namespace => "test"}; my $Var2; tie $Var2, "Win32::MMF::Shareable", "Var2"; print "Var2 is \"$Var2\"\n";
#!perl use Win32::MMF::Shareable; my $Var2; tie $Var2, "Win32::MMF::Shareable", "Var2", {namespace => "test"}; print "Var2 is \"$Var2\"\n";
#!perl use Win32::MMF::Shareable {namespace => "shareable"}; my $Var2; tie $Var2, "Win32::MMF::Shareable", "Var2"; print "Var2 is \"$Var2\"\n";
In reply to Win32::MMF::Shareable tie namespaces don't seem to work? by gowen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |