ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/Storable.pm
(Generate patch)

Comparing Coro/Coro/Storable.pm (file contents):
Revision 1.35 by root, Wed Nov 5 15:38:10 2008 UTC vs.
Revision 1.61 by root, Sat Feb 19 06:51:24 2011 UTC

68 68
69=cut 69=cut
70 70
71package Coro::Storable; 71package Coro::Storable;
72 72
73use strict qw(subs vars); 73use common::sense;
74no warnings;
75 74
76use Coro (); 75use Coro ();
77use Coro::Semaphore (); 76use Coro::Semaphore ();
78 77
79BEGIN { 78BEGIN {
83} 82}
84 83
85use Storable; 84use Storable;
86use base "Exporter"; 85use base "Exporter";
87 86
88our $VERSION = 4.804; 87our $VERSION = 5.37;
89our @EXPORT = qw(thaw freeze nfreeze blocking_thaw blocking_freeze blocking_nfreeze); 88our @EXPORT = qw(thaw freeze nfreeze blocking_thaw blocking_freeze blocking_nfreeze);
90 89
91our $GRANULARITY = 0.01; 90our $GRANULARITY = 0.01;
92 91
93my $lock = new Coro::Semaphore; 92my $lock = new Coro::Semaphore;
97} 96}
98 97
99# wrap xs functions 98# wrap xs functions
100for (qw(net_pstore pstore net_mstore mstore pretrieve mretrieve dclone)) { 99for (qw(net_pstore pstore net_mstore mstore pretrieve mretrieve dclone)) {
101 my $orig = \&{"Storable::$_"}; 100 my $orig = \&{"Storable::$_"};
102 *{"Storable::$_"} = sub { 101 *{"Storable::$_"} = eval 'sub (' . (prototype $orig) . ') {
103 my $guard = $lock->guard; 102 my $guard = $lock->guard;
104 &$orig 103 &$orig
105 }; 104 }';
106 die if $@; 105 die if $@;
107} 106}
108 107
109sub thaw($) { 108sub thaw($) {
110 open my $fh, "<:cede($GRANULARITY)", \$_[0] 109 open my $fh, "<:cede($GRANULARITY)", \$_[0]

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines