CUFP
Roger
I have just uploaded the Win32::MMF module to PAUSE, which will (hopefully) appear in CPAN soon. Big thanks to [PodMaster] for picking the namespace for me. And thanks to NetWallah for testing and ideas on OO :-)<br><br>
This module is primarily designed for inter-process and intra-process communication under Windows, using the Windows own native memory mapped file facility - the backbone of Windows virtual memory.<br><br>
The core of the module is written in XS for performance. This is the first release of the module so the functionalities are limited. The following is a demo on how to do intra/inter-process communication using the module. Any suggestions and beta-testing are greatly welcome, especially on locking. :-)<br><br>
<code>
use strict;
use warnings;
use Win32::MMF;
use Data::Dumper;
use CGI; # for testing of inter-process object transportation
# fork a process
defined(my $pid = fork()) or die "Can not fork a child process!";
if ($pid) {
my $ns1 = Win32::MMF->new ( -namespace => "My.data1" );
my $ns2 = Win32::MMF->new ( -namespace => "My.data2" );
my $cgi = new CGI;
my $data = {a=>[1,2,3], b=>4, c=>"A\0B\0C\0"};
$ns1->write($data); # autolocking by default
$ns2->write($cgi);
print "--- Sent ---\n";
print Dumper($data), "\n";
print Dumper($cgi), "\n";
sleep(1);
} else {
# in child
sleep(1);
my $ns1 = Win32::MMF->new ( -namespace => "My.data1",
-nocreate => 1 )
or die "Namespace does not exist!";
my $ns2 = Win32::MMF->new ( -namespace => "My.data2",
-nocreate => 1 )
or die "Namespace does not exist!";
my $data = $ns1->read();
my $cgi = $ns2->read();
print "--- Received ---\n";
print Dumper($data), "\n";
print Dumper($cgi), "\n";
print "--- Use Received Object ---\n";
# use the object from another process :-)
print $cgi->header(),
$cgi->start_html(), "\n",
$cgi->end_html(), "\n";
}
</code><br>
PS: Package source code is on CPAN.<br><br>