in reply to Re^2: Why won't this Deadlock?
in thread Why won't this Deadlock?
Hi Jambo Hamon,
Enjoy your vacation. When you come back, I'd likely have MCE 1.830 (bug fixes) and MCE::Shared 1.827 released on CPAN. The OO interface for shared objects makes it possible to not worry about mutex at the application level.
use MCE::Shared; my $val = MCE::Shared->scalar(0); $val->incr(); $val->incrby(20); $val->set(40); my @pairs = ('aa'..'zz'); my $oh = MCE::Shared->ordhash(); my $ha = MCE::Shared->hash(); $oh->assign( @pairs ); $ha->assign( @pairs ); $ha->set( counter => 0 ); $ha->incr('counter'); $ha->incrby('counter', 2); my $val = $ha->get('counter'); # Scoping works similarly to lexical scoping in Perl. # The shared object is destroyed upon leaving the scope. { my $ar = MCE::Shared->array(1..9); $ar->assign('aa'..'zz'); }
Passing a code reference via IPC isn't supported at this time. Perhaps, I can add filter support for STORE (set), FETCH (get) at a later time. I'm currently at a code freeze with MCE 1.830 and MCE::Shared 1.827.
use MCE::Shared; my $obj = MCE::Shared->scalar(0); $obj->filter_store_value( \&code ); $obj->filter_fetch_value( \&code );
Regards, Mario
|
|---|