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 :-)
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.
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. :-)
PS: Package source code is on CPAN.
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.
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. :-)
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"; }
PS: Package source code is on CPAN.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Win32::MMF (Windows Memory Mapped File) Support for Perl
by NetWallah (Canon) on Feb 06, 2004 at 00:35 UTC | |
by Roger (Parson) on Feb 06, 2004 at 00:53 UTC | |
Re: Win32::MMF - Memory Mapped File Support for Perl
by xiper (Friar) on Feb 09, 2004 at 06:06 UTC | |
by Roger (Parson) on Feb 10, 2004 at 04:49 UTC | |
by xiper (Friar) on Feb 11, 2004 at 04:31 UTC | |
by Roger (Parson) on Feb 12, 2004 at 06:32 UTC | |
Re: (Updated Again) Win32::MMF - Memory Mapped File Support for Perl
by xiper (Friar) on Feb 16, 2004 at 01:58 UTC |
Back to
Cool Uses for Perl