… | |
… | |
68 | =cut |
68 | =cut |
69 | |
69 | |
70 | package Coro::Storable; |
70 | package Coro::Storable; |
71 | |
71 | |
72 | use strict; |
72 | use strict; |
|
|
73 | no warnings; |
73 | |
74 | |
74 | use Coro (); |
75 | use Coro (); |
75 | use Coro::Semaphore (); |
76 | use Coro::Semaphore (); |
76 | |
77 | |
|
|
78 | BEGIN { |
|
|
79 | # suppress warnings |
|
|
80 | local $^W = 0; |
|
|
81 | require Storable; |
|
|
82 | } |
|
|
83 | |
77 | use Storable; |
84 | use Storable; |
78 | use base "Exporter"; |
85 | use base "Exporter"; |
79 | |
86 | |
80 | our $VERSION = 4.6; |
87 | our $VERSION = 4.742; |
81 | our @EXPORT = qw(thaw freeze nfreeze blocking_thaw blocking_freeze blocking_nfreeze); |
88 | our @EXPORT = qw(thaw freeze nfreeze blocking_thaw blocking_freeze blocking_nfreeze); |
82 | |
89 | |
83 | my $lock = new Coro::Semaphore; |
90 | my $lock = new Coro::Semaphore; |
84 | |
91 | |
85 | sub guard { |
92 | sub guard { |
… | |
… | |
157 | } |
164 | } |
158 | |
165 | |
159 | sub FILL { |
166 | sub FILL { |
160 | if ($next_cede <= time) { |
167 | if ($next_cede <= time) { |
161 | $next_cede = time + $GRANULARITY; # calling time() twice usually is a net win |
168 | $next_cede = time + $GRANULARITY; # calling time() twice usually is a net win |
162 | Coro::cede; |
169 | Coro::cede (); |
163 | } |
170 | } |
164 | |
171 | |
165 | read $_[1], my $buf, 512 |
172 | read $_[1], my $buf, 512 |
166 | or return undef; |
173 | or return undef; |
167 | |
174 | |