view release on metacpan or search on metacpan
ZabbixSender.pm view on Meta::CPAN
193194195196197198199200201202203# start sending
sub
_send {
my
(
$self
) =
@_
;
if
(
$self
->{delay}) {
Scalar::Util::weaken
$self
;
$self
->{delay_w} ||= AE::timer
$self
->{delay}, 0,
sub
{
delete
$self
->{delay_w};
$self
->{send_immediate} = 1;
$self
->_send2
unless
$self
->{sending}++;
};
ZabbixSender.pm view on Meta::CPAN
209210211212213214215216217218219# actually do send
sub
_send2 {
my
(
$self
) =
@_
;
Scalar::Util::weaken
$self
;
$self
->{connect_w} = AnyEvent::Socket::tcp_connect
$self
->{zhost},
$self
->{zport},
sub
{
my
(
$fh
) =
@_
;
$fh
or
return
$self
->_retry;
ZabbixSender.pm view on Meta::CPAN
view all matches for this distribution
283284285286287288289290291292293}
sub
_retry {
my
(
$self
) =
@_
;
Scalar::Util::weaken
$self
;
delete
$self
->{hdl};
my
$expire
= AE::now -
$self
->{queue_time};
while
(@{
$self
->{queue} } &&
$self
->{queue}[0][0] <
$expire
) {
view release on metacpan or search on metacpan
lib/AnyEvent/ZeroMQ/Handle.pm view on Meta::CPAN
89101112131415161718
lib/AnyEvent/ZeroMQ/Handle.pm view on Meta::CPAN
view all matches for this distribution
888990919293949596979899100101102103104105106107108
default
=>
sub
{ [] },
);
sub
_build_read_watcher {
my
$self
=
shift
;
weaken
$self
;
return
AnyEvent::ZeroMQ->io(
poll
=>
'r'
,
socket
=>
$self
->
socket
,
cb
=>
sub
{
$self
->
read
},
);
}
sub
_build_write_watcher {
my
$self
=
shift
;
weaken
$self
;
return
AnyEvent::ZeroMQ->io(
poll
=>
'w'
,
socket
=>
$self
->
socket
,
cb
=>
sub
{
$self
->
write
},
);
view release on metacpan or search on metacpan
lib/AnyMQ/Queue.pm view on Meta::CPAN
1234567891011package
AnyMQ::Queue;
use
strict;
use
Any::Moose;
use
AnyEvent;
use
Try::Tiny;
use
Time::HiRes;
has
id
=> (
is
=>
'rw'
,
isa
=>
'Str'
);
has
persistent
=> (
is
=>
"rw"
,
isa
=>
"Bool"
,
default
=>
sub
{ 0 });
lib/AnyMQ/Queue.pm view on Meta::CPAN
7475767778798081828384my
(
$self
,
$timeout
) =
@_
;
AnyEvent->timer(
after
=>
$timeout
||
$self
->timeout,
cb
=>
sub
{
weaken
$self
;
warn
"Timing out $self long-poll"
if
DEBUG;
if
(
$self
->on_timeout) {
$self
->on_timeout->(
$self
,
"timeout"
)
}
else
{
lib/AnyMQ/Queue.pm view on Meta::CPAN
view all matches for this distribution
96979899100101102103104105106107108109110
# reset garbage collection timeout with the long-poll timeout
# $timeout = 0 is a valid timeout for interval-polling
$timeout
= 55
unless
defined
$timeout
;
$self
->{timer} = AE::timer
$timeout
|| 55, 0,
sub
{
weaken
$self
;
warn
"long-poll timeout, flush and wait for client reconnect"
if
DEBUG;
$self
->_flush;
};
weaken
$self
->{timer};
# flush buffer for a long-poll client
$self
->_flush( @{
$self
->{buffer} })
if
@{
$self
->{buffer} };
}
view release on metacpan or search on metacpan
view all matches for this distribution
17981799180018011802180318041805180618071808sv_release_COW|||
sv_release_IVX|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.006000||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.006000||p
view release on metacpan or search on metacpan
lib/Apache/Solr.pm view on Meta::CPAN
17181920212223242526
lib/Apache/Solr.pm view on Meta::CPAN
view all matches for this distribution
66676869707172737475
$self
->{AS_retry_max} =
$args
->{retry_max} // 60;
$http_agent
=
$self
->{AS_agent} =
$args
->{agent} ||
$http_agent
|| LWP::UserAgent->new(
keep_alive
=>1);
weaken
$http_agent
;
$self
;
}
#---------------
view release on metacpan or search on metacpan
lib/Apache2/ASP/ASPDOM/Node.pm view on Meta::CPAN
23456789101112package
Apache2::ASP::ASPDOM::Node;
use
strict;
#==============================================================================
sub
new
{
lib/Apache2/ASP/ASPDOM/Node.pm view on Meta::CPAN
1819202122232425262728
events
=> {
before_appendChild
=> [ ],
after_appendChild
=> [ ],
},
},
$class
;
weaken(
$s
->{parentNode})
if
$s
->{parentNode};
return
$s
;
}
# end new()
#==============================================================================
lib/Apache2/ASP/ASPDOM/Node.pm view on Meta::CPAN
view all matches for this distribution
6869707172737475767778#==============================================================================
sub
parentNode
{
my
$s
=
shift
;
@_
? weaken(
$s
->{parentNode} =
shift
) :
$s
->{parentNode};
}
# end parentNode()
#==============================================================================
sub
appendChild
view release on metacpan or search on metacpan
view all matches for this distribution
22612262226322642265226622672268226922702271sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view release on metacpan or search on metacpan
view all matches for this distribution
22612262226322642265226622672268226922702271sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view release on metacpan or search on metacpan
view all matches for this distribution
22612262226322642265226622672268226922702271sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view release on metacpan or search on metacpan
lib/Apache2/SSI/URI.pm view on Meta::CPAN
view all matches for this distribution
809810811812813814815816817818819
_path_info_processed
=> 1,
};
$hash
->{document_path} =
$hash
->{document_uri};
$hash
->{apache_request} =
$self
->apache_request
if
(
$self
->apache_request );
my
$root
=
bless
(
$hash
=>
ref
(
$self
) );
# Scalar::Util::weaken( $copy );
$root
->{base_dir} =
$root
;
$root
->{base_uri} =
$root
;
$self
->{root} =
$root
;
return
(
$root
);
}
view release on metacpan or search on metacpan
view all matches for this distribution
22612262226322642265226622672268226922702271sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
184185186187188189190191192193194195196197198199200201202
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n"
.
" unless \$#_ > 0 or defined \$_[0]->{%s};\n"
,
weak_init
=>
" return do {\n"
.
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n"
.
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n"
.
" \$_[0]->{%s};\n"
.
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n"
,
return_if_get
=>
" return \$_[0]->{%s} unless \$#_ > 0;\n"
,
set
=>
" \$_[0]->{%s} = \$_[1];\n"
,
weaken
=>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n"
,
sub_end
=>
" return \$_[0]->{%s};\n}\n"
,
);
sub
field {
inc/Spiffy.pm view on Meta::CPAN
207208209210211212213214215216217
local
*paired_arguments
=
sub
{ (
qw(-package -init)
) };
Spiffy->parse_arguments(
@_
);
};
my
(
$field
,
$default
) =
@values
;
$package
=
$args
->{-
package
}
if
defined
$args
->{-
package
};
die
"Cannot have a default for a weakened field ($field)"
if
defined
$default
&&
$args
->{-weak};
return
if
defined
&{
"${package}::$field"
};
my
$default_string
=
(
ref
(
$default
) eq
'ARRAY'
and not
@$default
)
inc/Spiffy.pm view on Meta::CPAN
view all matches for this distribution
227228229230231232233234235236237}
$code
.=
sprintf
$code
{set_default},
$field
,
$default_string
,
$field
if
defined
$default
;
$code
.=
sprintf
$code
{return_if_get},
$field
;
$code
.=
sprintf
$code
{set},
$field
;
$code
.=
sprintf
$code
{weaken},
$field
,
$field
if
$args
->{-weak};
$code
.=
sprintf
$code
{sub_end},
$field
;
my
$sub
=
eval
$code
;
die
$@
if
$@;
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
184185186187188189190191192193194195196197198199200201202
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n"
.
" unless \$#_ > 0 or defined \$_[0]->{%s};\n"
,
weak_init
=>
" return do {\n"
.
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n"
.
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n"
.
" \$_[0]->{%s};\n"
.
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n"
,
return_if_get
=>
" return \$_[0]->{%s} unless \$#_ > 0;\n"
,
set
=>
" \$_[0]->{%s} = \$_[1];\n"
,
weaken
=>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n"
,
sub_end
=>
" return \$_[0]->{%s};\n}\n"
,
);
sub
field {
inc/Spiffy.pm view on Meta::CPAN
207208209210211212213214215216217
local
*paired_arguments
=
sub
{ (
qw(-package -init)
) };
Spiffy->parse_arguments(
@_
);
};
my
(
$field
,
$default
) =
@values
;
$package
=
$args
->{-
package
}
if
defined
$args
->{-
package
};
die
"Cannot have a default for a weakened field ($field)"
if
defined
$default
&&
$args
->{-weak};
return
if
defined
&{
"${package}::$field"
};
my
$default_string
=
(
ref
(
$default
) eq
'ARRAY'
and not
@$default
)
inc/Spiffy.pm view on Meta::CPAN
view all matches for this distribution
227228229230231232233234235236237}
$code
.=
sprintf
$code
{set_default},
$field
,
$default_string
,
$field
if
defined
$default
;
$code
.=
sprintf
$code
{return_if_get},
$field
;
$code
.=
sprintf
$code
{set},
$field
;
$code
.=
sprintf
$code
{weaken},
$field
,
$field
if
$args
->{-weak};
$code
.=
sprintf
$code
{sub_end},
$field
;
my
$sub
=
eval
$code
;
die
$@
if
$@;
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
184185186187188189190191192193194195196197198199200201202
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n"
.
" unless \$#_ > 0 or defined \$_[0]->{%s};\n"
,
weak_init
=>
" return do {\n"
.
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n"
.
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n"
.
" \$_[0]->{%s};\n"
.
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n"
,
return_if_get
=>
" return \$_[0]->{%s} unless \$#_ > 0;\n"
,
set
=>
" \$_[0]->{%s} = \$_[1];\n"
,
weaken
=>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n"
,
sub_end
=>
" return \$_[0]->{%s};\n}\n"
,
);
sub
field {
inc/Spiffy.pm view on Meta::CPAN
207208209210211212213214215216217
local
*paired_arguments
=
sub
{ (
qw(-package -init)
) };
Spiffy->parse_arguments(
@_
);
};
my
(
$field
,
$default
) =
@values
;
$package
=
$args
->{-
package
}
if
defined
$args
->{-
package
};
die
"Cannot have a default for a weakened field ($field)"
if
defined
$default
&&
$args
->{-weak};
return
if
defined
&{
"${package}::$field"
};
my
$default_string
=
(
ref
(
$default
) eq
'ARRAY'
and not
@$default
)
inc/Spiffy.pm view on Meta::CPAN
view all matches for this distribution
227228229230231232233234235236237}
$code
.=
sprintf
$code
{set_default},
$field
,
$default_string
,
$field
if
defined
$default
;
$code
.=
sprintf
$code
{return_if_get},
$field
;
$code
.=
sprintf
$code
{set},
$field
;
$code
.=
sprintf
$code
{weaken},
$field
,
$field
if
$args
->{-weak};
$code
.=
sprintf
$code
{sub_end},
$field
;
my
$sub
=
eval
$code
;
die
$@
if
$@;
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
184185186187188189190191192193194195196197198199200201202
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n"
.
" unless \$#_ > 0 or defined \$_[0]->{%s};\n"
,
weak_init
=>
" return do {\n"
.
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n"
.
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n"
.
" \$_[0]->{%s};\n"
.
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n"
,
return_if_get
=>
" return \$_[0]->{%s} unless \$#_ > 0;\n"
,
set
=>
" \$_[0]->{%s} = \$_[1];\n"
,
weaken
=>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n"
,
sub_end
=>
" return \$_[0]->{%s};\n}\n"
,
);
sub
field {
inc/Spiffy.pm view on Meta::CPAN
207208209210211212213214215216217
local
*paired_arguments
=
sub
{ (
qw(-package -init)
) };
Spiffy->parse_arguments(
@_
);
};
my
(
$field
,
$default
) =
@values
;
$package
=
$args
->{-
package
}
if
defined
$args
->{-
package
};
die
"Cannot have a default for a weakened field ($field)"
if
defined
$default
&&
$args
->{-weak};
return
if
defined
&{
"${package}::$field"
};
my
$default_string
=
(
ref
(
$default
) eq
'ARRAY'
and not
@$default
)
inc/Spiffy.pm view on Meta::CPAN
view all matches for this distribution
227228229230231232233234235236237}
$code
.=
sprintf
$code
{set_default},
$field
,
$default_string
,
$field
if
defined
$default
;
$code
.=
sprintf
$code
{return_if_get},
$field
;
$code
.=
sprintf
$code
{set},
$field
;
$code
.=
sprintf
$code
{weaken},
$field
,
$field
if
$args
->{-weak};
$code
.=
sprintf
$code
{sub_end},
$field
;
my
$sub
=
eval
$code
;
die
$@
if
$@;
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
184185186187188189190191192193194195196197198199200201202
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n"
.
" unless \$#_ > 0 or defined \$_[0]->{%s};\n"
,
weak_init
=>
" return do {\n"
.
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n"
.
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n"
.
" \$_[0]->{%s};\n"
.
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n"
,
return_if_get
=>
" return \$_[0]->{%s} unless \$#_ > 0;\n"
,
set
=>
" \$_[0]->{%s} = \$_[1];\n"
,
weaken
=>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n"
,
sub_end
=>
" return \$_[0]->{%s};\n}\n"
,
);
sub
field {
inc/Spiffy.pm view on Meta::CPAN
207208209210211212213214215216217
local
*paired_arguments
=
sub
{ (
qw(-package -init)
) };
Spiffy->parse_arguments(
@_
);
};
my
(
$field
,
$default
) =
@values
;
$package
=
$args
->{-
package
}
if
defined
$args
->{-
package
};
die
"Cannot have a default for a weakened field ($field)"
if
defined
$default
&&
$args
->{-weak};
return
if
defined
&{
"${package}::$field"
};
my
$default_string
=
(
ref
(
$default
) eq
'ARRAY'
and not
@$default
)
inc/Spiffy.pm view on Meta::CPAN
view all matches for this distribution
227228229230231232233234235236237}
$code
.=
sprintf
$code
{set_default},
$field
,
$default_string
,
$field
if
defined
$default
;
$code
.=
sprintf
$code
{return_if_get},
$field
;
$code
.=
sprintf
$code
{set},
$field
;
$code
.=
sprintf
$code
{weaken},
$field
,
$field
if
$args
->{-weak};
$code
.=
sprintf
$code
{sub_end},
$field
;
my
$sub
=
eval
$code
;
die
$@
if
$@;
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
184185186187188189190191192193194195196197198199200201202
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n"
.
" unless \$#_ > 0 or defined \$_[0]->{%s};\n"
,
weak_init
=>
" return do {\n"
.
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n"
.
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n"
.
" \$_[0]->{%s};\n"
.
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n"
,
return_if_get
=>
" return \$_[0]->{%s} unless \$#_ > 0;\n"
,
set
=>
" \$_[0]->{%s} = \$_[1];\n"
,
weaken
=>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n"
,
sub_end
=>
" return \$_[0]->{%s};\n}\n"
,
);
sub
field {
inc/Spiffy.pm view on Meta::CPAN
207208209210211212213214215216217
local
*paired_arguments
=
sub
{ (
qw(-package -init)
) };
Spiffy->parse_arguments(
@_
);
};
my
(
$field
,
$default
) =
@values
;
$package
=
$args
->{-
package
}
if
defined
$args
->{-
package
};
die
"Cannot have a default for a weakened field ($field)"
if
defined
$default
&&
$args
->{-weak};
return
if
defined
&{
"${package}::$field"
};
my
$default_string
=
(
ref
(
$default
) eq
'ARRAY'
and not
@$default
)
inc/Spiffy.pm view on Meta::CPAN
view all matches for this distribution
227228229230231232233234235236237}
$code
.=
sprintf
$code
{set_default},
$field
,
$default_string
,
$field
if
defined
$default
;
$code
.=
sprintf
$code
{return_if_get},
$field
;
$code
.=
sprintf
$code
{set},
$field
;
$code
.=
sprintf
$code
{weaken},
$field
,
$field
if
$args
->{-weak};
$code
.=
sprintf
$code
{sub_end},
$field
;
my
$sub
=
eval
$code
;
die
$@
if
$@;
view release on metacpan or search on metacpan
devel/run-download-dialog.pl view on Meta::CPAN
view all matches for this distribution
353637383940414243{
my
$dialog
= App::Chart::Gtk2::DownloadDialog->new;
$dialog
->destroy;
Devel::FindRef::track (
$dialog
);
Scalar::Util::weaken (
$dialog
);
defined
$dialog
?
"defined\n"
:
"not defined\n"
;
exit
0;
}
view release on metacpan or search on metacpan
scripts/dex view on Meta::CPAN
1104111042110431104411045110461104711048110491105011051package
YAML::PP::Schema::Include;
our
$VERSION
=
'0.027'
;
# VERSION
sub
new {
my
(
$class
,
%args
) =
@_
;
scripts/dex view on Meta::CPAN
1108111082110831108411085110861108711088110891109011091sub
allow_absolute {
$_
[0]->{allow_absolute} }
sub
yp {
my
(
$self
,
$yp
) =
@_
;
if
(
@_
== 2) {
$self
->{yp} =
$yp
;
weaken
$self
->{yp};
return
$yp
;
}
return
$self
->{yp};
}
scripts/dex view on Meta::CPAN
scripts/dex view on Meta::CPAN
1423114232142331423414235142361423714238142391424014241Scalar::Util - A selection of general-utility
scalar
subroutines
=head1 SYNOPSIS
use Scalar::Util qw(blessed dualvar isdual readonly refaddr reftype
tainted weaken isweak isvstring looks_like_number
set_prototype);
# and other useful utils appearing below
=head1 DESCRIPTION
scripts/dex view on Meta::CPAN
14303143041430514306143071430814309143101431114312143131431414315Note that
for
internal reasons, all precompiled regexps (C<
qr/.../
>) are
on these but C<reftype()> will
return
the underlying C structure type of
C<
"REGEXP"
> in all capitals.
=head2 weaken
weaken( $ref );
The lvalue C<$ref> will be turned into a weak reference. This means that it
will not hold a reference count on the object it references. Also, when the
reference count on that object reaches zero, the reference will be set to
undef. This function mutates the lvalue passed as its argument and returns no
scripts/dex view on Meta::CPAN
143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381the object being DESTROY-ed at its usual
time
.
{
my
$var
;
$ref
= \
$var
;
weaken(
$ref
);
# Make $ref a weak reference
}
# $ref is now undef
Note that
if
you take a copy of a
scalar
with
a weakened reference, the copy
will be a strong reference.
my
$var
;
my
$foo
= \
$var
;
weaken(
$foo
);
# Make $foo a weak reference
my
$bar
=
$foo
;
# $bar is now a strong reference
This may be less obvious in other situations, such as C<
grep
()>,
for
instance
when
grepping through a list of weakened references to objects that may have
been destroyed already:
@object
=
grep
{
defined
}
@object
;
This will indeed remove all references to destroyed objects, but the remaining
references to objects will be strong, causing the remaining objects to never be
destroyed because there is now always a strong reference to them in the
@object
array.
=head2 unweaken
unweaken( $ref );
I<Since version 1.36.>
The lvalue C<REF> will be turned from a weak reference back into a normal
(strong) reference again. This function mutates the lvalue passed as its
argument and returns no value. This undoes the action performed by
L</weaken>.
This function is slightly neater and more convenient than the
otherwise-equivalent code
my $tmp = $REF;
undef $REF;
$REF = $tmp;
(because in particular, simply assigning a weak reference back to itself does
not work to unweaken it; C<$REF = $REF> does not work).
=head2 isweak
my $weak = isweak( $ref );
Returns true if C<$ref> is a weak reference.
$ref = \$foo;
$weak = isweak($ref); # false
weaken($ref);
$weak = isweak($ref); # true
B<NOTE>: Copying a weak reference creates a normal, strong, reference.
$copy = $ref;
scripts/dex view on Meta::CPAN
view all matches for this distribution
1451014511145121451314514145151451614517145181451914520Copyright (c) 1997-2007 Graham Barr <gbarr
@pobox
.com>. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
Additionally L</weaken> and L</isweak> which are
Copyright (c) 1999 Tuomas J. Lukka <lukka
@iki
.fi>. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as perl itself.
view release on metacpan or search on metacpan
lib/App/DubiousHTTP/TestServer.pm view on Meta::CPAN
123456789
lib/App/DubiousHTTP/TestServer.pm view on Meta::CPAN
6970717273747576777879my
(
$cl
,
$response
,
$sslctx
) =
@_
;
my
$addr
=
$cl
->sockhost.
':'
.
$cl
->sockport;
$DEBUG
&& _debug(
"new client from $addr"
);
$clients
{
fileno
(
$cl
)}{
time
} =
time
();
weaken(
my
$wcl
=
$cl
);
$clients
{
fileno
(
$cl
)}{fd} =
$wcl
;
$SELECT
->timeout(
$cl
,5,
sub
{ delete_client(
$wcl
)
if
$wcl
});
return
_install_check_https(
$cl
,
$response
,
$sslctx
)
if
$sslctx
;
return
_install_http(
$cl
,
$response
);
lib/App/DubiousHTTP/TestServer.pm view on Meta::CPAN
367368369370371372373374375376377
}
return
$close
;
}
package
App::DubiousHTTP::TestServer::Select;
my
$maxfn
= 0;
my
@handler
;
my
@didit
;
lib/App/DubiousHTTP/TestServer.pm view on Meta::CPAN
view all matches for this distribution
397398399400401402403404405406407sub
handler {
my
(
$self
,
$cl
,
%sub
) =
@_
;
defined
(
my
$fn
=
fileno
(
$cl
) ) or
die
"invalid fd"
;
$maxfn
=
$fn
if
$fn
>
$maxfn
;
weaken(
my
$wcl
=
$cl
);
while
(
my
(
$rw
,
$sub
) =
each
%sub
) {
$sub
= [
$sub
]
if
ref
(
$sub
) eq
'CODE'
;
splice
(
@$sub
,1,0,
$wcl
);
$handler
[
$fn
][
$rw
] =
$sub
;
$DEBUG
&& _debug(
"add handler($fn,$rw)"
);
view release on metacpan or search on metacpan
lib/App/Easer/V2.pm view on Meta::CPAN
7879808182838485868788package
App::Easer::V2::Command;
# some stuff can be managed via a hash reference kept in a "slot",
# allowing for overriding should be easy either with re-defining the
# "slot" method, or overriding the sub-method relying on it. The name of
# the slot is the same as the name of the actual package that $self is
lib/App/Easer/V2.pm view on Meta::CPAN
174175176177178179180181182183184sub
child (
$self
,
@newval
) {
my
$slot
=
$self
->slot;
if
(
@newval
) {
$slot
->{child} =
$newval
[0];
weaken(
$slot
->{child});
}
return
$slot
->{child};
}
sub
is_leaf (
$self
) { !
defined
(
$self
->child) }
sub
leaf (
$self
) {
lib/App/Easer/V2.pm view on Meta::CPAN
view all matches for this distribution
187188189190191192193194195
my
$retval
=
$self
;
while
(
defined
(
my
$parent
=
$retval
->child)) {
$retval
=
$parent
;
}
$slot
->{leaf} =
$retval
;
weaken(
$slot
->{leaf});
}
return
$slot
->{leaf};
}
view release on metacpan or search on metacpan
lib/App/Glacier/Command/Get.pm view on Meta::CPAN
view all matches for this distribution
276277278279280281282283284285286my
$part_idx
=
$job_idx
*
$job_parts
;
# Offset in file
my
$off
=
$part_idx
*
$part_size
;
# Number of retries in case of failure
my
$retries
=
$self
->cf_transfer_param(
qw(download retries)
);
Scalar::Util::weaken(
$p
);
for
(
my
$j
= 0;
$j
<
$job_parts
;
$j
++,
$part_idx
++,
$off
+=
$part_size
) {
last
if
$off
>=
$archive_size
;
if
(
$part_size
>
$archive_size
-
$off
) {
$part_size
=
$archive_size
-
$off
;
view release on metacpan or search on metacpan
examples/DelayRequest.pm view on Meta::CPAN
678910111213141516use
Net::IMP;
use
Net::IMP::HTTP;
use
Net::IMP::Debug;
sub
RTYPES { ( IMP_PASS ) }
sub
new_analyzer {
my
(
$class
,
%args
) =
@_
;
examples/DelayRequest.pm view on Meta::CPAN
view all matches for this distribution
4445464748495051525354
$self
->run_callback([ IMP_PASS,0,IMP_MAXOFFSET ]);
return
;
}
}
weaken(
my
$wself
=
$self
);
$self
->{delayed} =
$self
->{factory_args}{eventlib}->timer(
$self
->{factory_args}{delay} || 0.5,
sub
{
# pass thru everything
$wself
or
return
;
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
184185186187188189190191192193194195196197198199200201202
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n"
.
" unless \$#_ > 0 or defined \$_[0]->{%s};\n"
,
weak_init
=>
" return do {\n"
.
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n"
.
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n"
.
" \$_[0]->{%s};\n"
.
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n"
,
return_if_get
=>
" return \$_[0]->{%s} unless \$#_ > 0;\n"
,
set
=>
" \$_[0]->{%s} = \$_[1];\n"
,
weaken
=>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n"
,
sub_end
=>
" return \$_[0]->{%s};\n}\n"
,
);
sub
field {
inc/Spiffy.pm view on Meta::CPAN
207208209210211212213214215216217
local
*paired_arguments
=
sub
{ (
qw(-package -init)
) };
Spiffy->parse_arguments(
@_
);
};
my
(
$field
,
$default
) =
@values
;
$package
=
$args
->{-
package
}
if
defined
$args
->{-
package
};
die
"Cannot have a default for a weakened field ($field)"
if
defined
$default
&&
$args
->{-weak};
return
if
defined
&{
"${package}::$field"
};
my
$default_string
=
(
ref
(
$default
) eq
'ARRAY'
and not
@$default
)
inc/Spiffy.pm view on Meta::CPAN
view all matches for this distribution
227228229230231232233234235236237}
$code
.=
sprintf
$code
{set_default},
$field
,
$default_string
,
$field
if
defined
$default
;
$code
.=
sprintf
$code
{return_if_get},
$field
;
$code
.=
sprintf
$code
{set},
$field
;
$code
.=
sprintf
$code
{weaken},
$field
,
$field
if
$args
->{-weak};
$code
.=
sprintf
$code
{sub_end},
$field
;
my
$sub
=
eval
$code
;
die
$@
if
$@;
view release on metacpan or search on metacpan
kritika.fatpack view on Meta::CPAN
view all matches for this distribution
15201521152215231524152515261527152815291530$fatpacked
{
"Test/Deep/Cache.pm"
} =
'#line '
.(1+__LINE__).
' "'
.__FILE__."\
"\n"
.
<<'TEST_DEEP_CACHE';
use strict;use warnings;package Test::Deep::Cache;use Test::Deep::Cache::Simple;sub new {my$pkg=shift;my$self=bless {},$pkg;$self->{expects}=[Test::Deep::Cache::Simple->new];$self->{normal}=[Test::Deep::Cache::Simple->new];$self->local;return$self}...
TEST_DEEP_CACHE
$fatpacked
{
"Test/Deep/Cache/Simple.pm"
} =
'#line '
.(1+__LINE__).
' "'
.__FILE__."\
"\n"
.
<<'TEST_DEEP_CACHE_SIMPLE';
use strict;use warnings;package Test::Deep::Cache::Simple;use Carp qw(confess);use Scalar::Util qw(refaddr);BEGIN {if (grep /^weaken$/,@Scalar::Util::EXPORT_FAIL){*weaken=sub {}}else {Scalar::Util->import('weaken')}}sub new {my$pkg=shift;my$self=bl...
TEST_DEEP_CACHE_SIMPLE
$fatpacked
{
"Test/Deep/Class.pm"
} =
'#line '
.(1+__LINE__).
' "'
.__FILE__."\
"\n"
.<<
'TEST_DEEP_CLASS'
;
use
strict;
use
warnings;
package
Test::Deep::Class;
use
Test::Deep::Cmp;
sub
init {
my
$self
=
shift
;
my
$snobby
=
shift
;
my
$val
=
shift
;
$self
->{snobby}=
$snobby
;
$self
->{val}=
$val
}
sub
descend {
my
$self
=
shift
;
my
$got
=
shift
;
local
$Test::Deep::Snobby
=
$self
->{snobby};Te...
TEST_DEEP_CLASS
view release on metacpan or search on metacpan
lib/App/MHFS.pm view on Meta::CPAN
381382383384385386387388389390391
lib/App/MHFS.pm view on Meta::CPAN
11331134113511361137113811391140114111421143
lib/App/MHFS.pm view on Meta::CPAN
11621163116411651166116711681169117011711172sub
new {
my
(
$class
,
$client
) =
@_
;
my
%self
= (
'client'
=>
$client
);
bless
\
%self
,
$class
;
weaken(
$self
{
'client'
});
#don't allow Request to keep client alive
$self
{
'on_read_ready'
} = \
&want_request_line
;
$self
{
'outheaders'
}{
'X-MHFS-CONN-ID'
} =
$client
->{
'outheaders'
}{
'X-MHFS-CONN-ID'
};
$self
{
'rl'
} = 0;
# we want the request
$client
->SetEvents(POLLIN | MHFS::EventLoop::Poll->ALWAYSMASK );
lib/App/MHFS.pm view on Meta::CPAN
20382039204020412042204320442045204620472048use
IO::Socket::INET;
use
Data::Dumper;
use
Carp;
$SIG
{ __DIE__ } =
sub
{ Carp::confess(
@_
) };
sub
new {
lib/App/MHFS.pm view on Meta::CPAN
20572058205920602061206220632064206520662067}
# add a connection timeout timer
sub
AddClientCloseTimer {
my
(
$self
,
$timelength
,
$id
,
$is_requesttimeout
) =
@_
;
weaken(
$self
);
#don't allow this timer to keep the client object alive
my
$server
=
$self
->{
'server'
};
say
"CCT | add timer: $id"
;
$server
->{
'evp'
}->add_timer(
$timelength
, 0,
sub
{
if
(!
defined
$self
) {
say
"CCT | $id self undef"
;
lib/App/MHFS.pm view on Meta::CPAN
2420242124222423242424252426242724282429243024312432243324342435package
MHFS::FD::Reader {
sub
new {
my
(
$class
,
$process
,
$fd
,
$func
) =
@_
;
my
%self
= (
'time'
=> clock_gettime(CLOCK_MONOTONIC),
'process'
=>
$process
,
'fd'
=>
$fd
,
'onReadReady'
=>
$func
);
say
"PID "
.
$self
{
'process'
}{
'pid'
} .
'FD '
.
$self
{
'fd'
};
weaken(
$self
{
'process'
});
return
bless
\
%self
,
$class
;
}
sub
onReadReady {
my
(
$self
) =
@_
;
lib/App/MHFS.pm view on Meta::CPAN
2463246424652466246724682469247024712472247324742475247624772478package
MHFS::FD::Writer {
sub
new {
my
(
$class
,
$process
,
$fd
,
$func
) =
@_
;
my
%self
= (
'time'
=> clock_gettime(CLOCK_MONOTONIC),
'process'
=>
$process
,
'fd'
=>
$fd
,
'onWriteReady'
=>
$func
);
say
"PID "
.
$self
{
'process'
}{
'pid'
} .
'FD '
.
$self
{
'fd'
};
weaken(
$self
{
'process'
});
return
bless
\
%self
,
$class
;
}
sub
onWriteReady {
my
(
$self
) =
@_
;
lib/App/MHFS.pm view on Meta::CPAN
25112512251325142515251625172518251925202521use
IPC::Open3;
use
Data::Dumper;
use
Devel::Peek;
use
Carp;
$SIG
{ __DIE__ } =
sub
{ Carp::confess(
@_
) };
lib/App/MHFS.pm view on Meta::CPAN
37253726372737283729373037313732373337343735
lib/App/MHFS.pm view on Meta::CPAN
44964497449844994500450145024503450445054506use
Data::Dumper;
use
Encode;
use
URI::Escape;
MHFS::Util->
import
();
BEGIN {
if
( ! (
eval
"use JSON; 1"
)) {
eval
"use JSON::PP; 1"
or
die
"No implementation of JSON available"
;
lib/App/MHFS.pm view on Meta::CPAN
46304631463246334634463546364637463846394640
return
-1;
}
sub
downloadAndServe {
my
(
$self
,
$request
,
$video
) =
@_
;
weaken(
$request
);
my
$filename
=
$video
->{
'out_filepath'
};
my
$sendit
=
sub
{
# we can send the file
lib/App/MHFS.pm view on Meta::CPAN
54895490549154925493549454955496549754985499MHFS::Util->
import
(
qw(decode_UTF_8 encode_UTF_8 base64url_to_str str_to_base64url uri_escape_path_utf8)
);
BEGIN {
if
( ! (
eval
"use JSON; 1"
)) {
lib/App/MHFS.pm view on Meta::CPAN
62406241624262436244624562466247624862496250# slow path, download it
$request
->{client}{server}{settings}{TMDB} or
last
;
my
$searchname
=
$medianame
;
$searchname
=~ s/\s\(\d\d\d\d\)//
if
(
$mediatype
eq
'movies'
);
say
"searchname $searchname"
;
weaken(
$request
);
_TMDB_api_promise(
$request
->{client}{server},
'search/'
.
$params
->{search}, {
'query'
=>
$searchname
})->then(
sub
{
if
(
$metadatatype
eq
'plot'
|| ! -f
"$metadir/plot.txt"
) {
make_path(
$metadir
);
MHFS::Util::write_file(
"$metadir/plot.txt"
,
$_
[0]->{results}[0]{overview});
}
lib/App/MHFS.pm view on Meta::CPAN
6324632563266327632863296330633163326333package
MHFS::Plugin::GetVideo {
no
warnings
"portable"
;
lib/App/MHFS.pm view on Meta::CPAN
view all matches for this distribution
64776478647964806481648264836484648564866487# deprecated
$video
{
'pid'
} = ASYNC(\
&shellcmd_unlock
, \
@cmd
,
$video
{
'out_filepath'
});
# our file isn't ready yet, so create a timer to check the progress and act
weaken(
$request
);
# the only one who should be keeping $request alive is the client
$request
->{
'client'
}{
'server'
}{
'evp'
}->add_timer(0, 0,
sub
{
if
(!
defined
$request
) {
say
"\$request undef, ignoring CB"
;
return
undef
;
}
view release on metacpan or search on metacpan
lib/App/MechaCPAN.pm view on Meta::CPAN
661662663664665666667668669670671
lib/App/MechaCPAN.pm view on Meta::CPAN
view all matches for this distribution
674675676677678679680681682683{
my
$pwd
= App::MechaCPAN::get_project_dir;
$dest_dir
= \
"$pwd/local"
;
bless
$dest_dir
;
$result
=
$dest_dir
;
weaken
$dest_dir
;
}
mkdir
$dest_dir
unless
-d
$dest_dir
;
view release on metacpan or search on metacpan
t/unit/glacier/inventory_csv.t view on Meta::CPAN
view all matches for this distribution
242526272829303132
view release on metacpan or search on metacpan
lib/App/Netdisco/AnyEvent/Nbtstat.pm view on Meta::CPAN
view all matches for this distribution
2324252627282930313233$timeout
= 0.5
unless
defined
$timeout
;
my
$self
=
bless
{
interval
=>
$interval
,
timeout
=>
$timeout
,
%args
},
$class
;
Scalar::Util::weaken(
my
$wself
=
$self
);
socket
my
$fh4
, AF_INET, Socket::SOCK_DGRAM(), 0
or Carp::croak
"Unable to create socket : $!"
;
AnyEvent::Util::fh_nonblocking
$fh4
, 1;
view release on metacpan or search on metacpan
t/files/moby11.txt view on Meta::CPAN
104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460upon the Islanders to assist him in the laborious business of heaving
down the ship to stop the leak. But to such unresting vigilance over
their dangerous allies was this small band of whites necessitated,
both by night and by day, and so extreme was the hard work they underwent,
that upon the vessel being ready again
for
sea, they were in such
a weakened condition that the captain durst not put off
with
them
in so heavy a vessel. After taking counsel
with
his officers,
he anchored the ship as far off shore as possible; loaded and ran
out his two cannon from the bows; stacked his muskets on the poop;
and warning the Islanders not to approach the ship at their peril,
took one man
with
him, and setting the sail of his best whale-boat,
t/files/moby11.txt view on Meta::CPAN
view all matches for this distribution
191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167But as all
else
in him thinned, and his cheek-bones grew sharper,
his eyes, nevertheless, seemed growing fuller and fuller;
they became of a strange softness of lustre; and mildly but
deeply looked out at you there from his sickness, a wondrous
testimony to that immortal health in him which could not
die
,
or be weakened. And like circles on the water, which, as they
grow fainter, expand; so his eyes seemed rounding and rounding,
like the rings of Eternity. An awe that cannot be named would
steal over you as you sat by the side of this waning savage,
and saw as strange things in his face, as any beheld who were
bystanders
when
Zoroaster died. For whatever is truly wondrous