| 1 | # Copyright 2008, 2009, 2010, 2011, 2012, 2014, 2024 Kevin Ryde | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # This file is part of Glib-Ex-ObjectBits. | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # Glib-Ex-ObjectBits is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 6 | # it under the terms of the GNU General Public License as published by the | ||||||||||||||||||||||||||||
| 7 | # Free Software Foundation; either version 3, or (at your option) any later | ||||||||||||||||||||||||||||
| 8 | # version. | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | # Glib-Ex-ObjectBits is distributed in the hope that it will be useful, but | ||||||||||||||||||||||||||||
| 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||||||||||||||||||||||||||||
| 12 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||||||||||||||||||||||||||||
| 13 | # for more details. | ||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||
| 15 | # You should have received a copy of the GNU General Public License along | ||||||||||||||||||||||||||||
| 16 | # with Glib-Ex-ObjectBits. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | package Glib::Ex::FreezeNotify; | ||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use 5.008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use Scalar::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use Devel::GlobalDestruction 'in_global_destruction'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | our $VERSION = 17; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 29 | 0 | my $self = bless [], $class; | |||||||||||||||||||||||||||
| 30 | 0 | $self->add (@_); | |||||||||||||||||||||||||||
| 31 | 0 | return $self; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub add { | ||||||||||||||||||||||||||
|
Subroutine
add: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 36 | ### FreezeNotify add(): "@_" | ||||||||||||||||||||||||||||
| 37 | 0 | foreach my $object (@_) { | |||||||||||||||||||||||||||
| 38 | 0 | $object->freeze_notify; | |||||||||||||||||||||||||||
| 39 | 0 | push @$self, $object; | |||||||||||||||||||||||||||
| 40 | 0 | Scalar::Util::weaken ($self->[-1]); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 45 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 46 | ### FreezeNotify DESTROY() | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | while (@$self) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 0 | my $object = pop @$self; | |||||||||||||||||||||||||||
| 49 | 0 | ▶ | if (defined $object # possible undef by weakening | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $object and not &in_global_destruction()
MC/DC0%0/2
defined $object and not &in_global_destruction()
defined $object
not &in_global_destruction()
Truth table0%0/3
A and not(B)
A= defined $objectB= not &in_global_destruction()
| |||||||||||||||||||||||||||||
| 50 | && ! in_global_destruction()) { | ||||||||||||||||||||||||||||
| 51 | ### FreezeNotify thaw: "$object" | ||||||||||||||||||||||||||||
| 52 | 0 | $object->thaw_notify; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 1 | 1; | |||||||||||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||||||||||