文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>[Perl]IPC进程间内存共享

[Perl]IPC进程间内存共享

时间:2010-12-30  来源:snowtty

[Perl]IPC进程间内存共享

#!/usr/bin/perl -w

#test_server run under administrator
use strict;
use IPC::Shareable;
my $glue = 'test.key';
my %options = (
    create => 1,
    exclusive => 0,
    mode => 0644,
    destroy => 1,
);
my @arr;
tie @arr, 'IPC::Shareable', $glue, { %options } or die "server: tie failed\n";
@arr = ();
while (1) {
        print "Input:";
        my $input=<STDIN>;
        chomp $input;
        if (defined $input) {
                push(@arr,$input);
        }
        print "\@arr:@arr\n";
}
exit;


 

 

#!/usr/bin/perl -w

#test_client run under administrator

use strict;
use IPC::Shareable;
my $glue = 'test.key';
my %options = (
    create => 0,
    exclusive => 0,
    mode => '0644',
    destroy => 0,
    size=>65536 #size must less then 65536
    );
my @arr;
my $ipch=tie @arr, 'IPC::Shareable', $glue, { %options } or die "client: tie failed\n";
while(1) {
        if (scalar @arr > 0) {
                $ipch->shlock;
                my $str=shift @arr;
                $ipch->shunlock;
                print "output:$str\n";
        } else {
                sleep 3;
        }
}
exit;

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载