line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Apache-Singleton |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is copyright (c) 2009 by Michael Schout. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Apache::Singleton::Process; |
11
|
|
|
|
|
|
|
$Apache::Singleton::Process::VERSION = '0.17'; |
12
|
|
|
|
|
|
|
# ABSTRACT: One instance per One Process |
13
|
|
|
|
|
|
|
|
14
|
7
|
|
|
7
|
|
45992
|
use strict; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
159
|
|
15
|
7
|
|
|
7
|
|
28
|
use warnings; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
174
|
|
16
|
|
|
|
|
|
|
|
17
|
7
|
|
|
7
|
|
27
|
use base 'Apache::Singleton'; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
648
|
|
18
|
|
|
|
|
|
|
|
19
|
7
|
|
|
7
|
|
53
|
no strict 'refs'; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
681
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my %INSTANCES; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _get_instance { |
24
|
14
|
|
|
14
|
|
15
|
my $class = shift; |
25
|
|
|
|
|
|
|
|
26
|
14
|
|
33
|
|
|
41
|
$class = ref $class || $class; |
27
|
|
|
|
|
|
|
|
28
|
14
|
|
|
|
|
27
|
return $INSTANCES{$class}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _set_instance { |
32
|
6
|
|
|
6
|
|
13
|
my($class, $instance) = @_; |
33
|
|
|
|
|
|
|
|
34
|
6
|
|
33
|
|
|
17
|
$class = ref $class || $class; |
35
|
|
|
|
|
|
|
|
36
|
6
|
|
|
|
|
14
|
$INSTANCES{$class} = $instance; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
END { |
40
|
|
|
|
|
|
|
# dereferences and causes orderly destruction of all instances |
41
|
7
|
|
|
7
|
|
10853
|
undef(%INSTANCES); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |