lib/Mojo/IOLoop/ReadWriteProcess/CGroup/v2.pm

filter: Statementstmt 100% 74 / 74 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 30 / 30 Podpod 0.0% 0 / 14 totaltotal 88.1% 104 / 118 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/Mojo/IOLoop/ReadWriteProcess/CGroup/v1/Memory.pm ↑ Summary
1 package Mojo::IOLoop::ReadWriteProcess::CGroup::v2;
2  
3 # Refer to https://www.kernel.org/doc/Documentation/cgroup-v2.txt for details
4  
5 15 ▶use Mojo::Base 'Mojo::IOLoop::ReadWriteProcess::CGroup';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 15 ▶use Mojo::File 'path';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 15 ▶use Mojo::Collection 'c';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 15 our @EXPORT_OK = qw(cgroup);
10 15 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 15 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
13 15 PROCS_INTERFACE => 'cgroup.procs',
14 TYPE_INTERFACE => 'cgroup.type',
15 THREADS_INTERFACE => 'cgroup.threads',
16 EVENTS_INTERFACE => 'cgroup.events',
17 CONTROLLERS_INTERFACE => 'cgroup.controllers',
18 SUBTREE_CONTROL_INTERFACE => 'cgroup.subtree_control',
19 MAX_DESCENDANT_INTERFACE => 'cgroup.max.descendants',
20 MAX_DEPTH_INTERFACE => 'cgroup.max.depth',
21 STAT_INTERFACE => 'cgroup.stat',
22 15 };
23  
24 15 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
25 15 ▶use Mojo::IOLoop::ReadWriteProcess::CGroup::v2::IO;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 15 ▶use Mojo::IOLoop::ReadWriteProcess::CGroup::v2::CPU;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 15 ▶use Mojo::IOLoop::ReadWriteProcess::CGroup::v2::Memory;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 15 ▶use Mojo::IOLoop::ReadWriteProcess::CGroup::v2::PID;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 15 ▶use Mojo::IOLoop::ReadWriteProcess::CGroup::v2::RDMA;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 1 ▶has io => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
32 1 my $io = Mojo::IOLoop::ReadWriteProcess::CGroup::v2::IO->new(cgroup => shift);
33 1 Scalar::Util::weaken $io->{cgroup};
34 1 return $io;
35 15 };
36  
37 1 ▶has cpu => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
38 1 my $cpu
39 = Mojo::IOLoop::ReadWriteProcess::CGroup::v2::CPU->new(cgroup => shift);
40 1 Scalar::Util::weaken $cpu->{cgroup};
41 1 return $cpu;
42 15 };
43  
44 1 ▶has memory => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
45 1 my $memory
46 = Mojo::IOLoop::ReadWriteProcess::CGroup::v2::Memory->new(cgroup => shift);
47 1 Scalar::Util::weaken $memory->{cgroup};
48 1 return $memory;
49 15 };
50  
51 1 ▶has pid => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
52 1 my $pid
53 = Mojo::IOLoop::ReadWriteProcess::CGroup::v2::PID->new(cgroup => shift);
54 1 Scalar::Util::weaken $pid->{cgroup};
55 1 return $pid;
56 15 };
57  
58 1 ▶has rdma => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
59 1 my $rdma
60 = Mojo::IOLoop::ReadWriteProcess::CGroup::v2::RDMA->new(cgroup => shift);
61 1 Scalar::Util::weaken $rdma->{cgroup};
62 1 return $rdma;
63 15 };
64  
65 # CGroups process interface
66 4 ▶sub add_process { shift->_appendln(+PROCS_INTERFACE() => pop) }
Subroutine add_process: called CC=1 SCAR=0.0
Pod undocumented
67  
68 2 ▶sub process_list { shift->_list(PROCS_INTERFACE) }
Subroutine process_list: called CC=1 SCAR=0.0
Pod undocumented
69 2 ▶sub processes { c(shift->_listarray(PROCS_INTERFACE)) }
Subroutine processes: called CC=1 SCAR=0.0
Pod undocumented
70  
71 8 ▶sub contains_process { shift->_contains(+PROCS_INTERFACE() => pop) }
Subroutine contains_process: called CC=1 SCAR=0.0
Pod undocumented
72  
73 # CGroups thread interface
74 2 ▶sub add_thread { shift->_appendln(+THREADS_INTERFACE() => pop) }
Subroutine add_thread: called CC=1 SCAR=0.0
Pod undocumented
75  
76 1 ▶sub thread_list { shift->_list(THREADS_INTERFACE) }
Subroutine thread_list: called CC=1 SCAR=0.0
Pod undocumented
77  
78 4 ▶sub contains_thread { shift->_contains(+THREADS_INTERFACE() => pop) }
Subroutine contains_thread: called CC=1 SCAR=0.0
Pod undocumented
79  
80 # CGroups event interface
81 1 ▶sub populated { shift->_list(EVENTS_INTERFACE) }
Subroutine populated: called CC=1 SCAR=0.0
Pod undocumented
82  
83 # CGroups type interface
84 2 ▶sub type { shift->_setget(+TYPE_INTERFACE() => pop) }
Subroutine type: called CC=1 SCAR=0.0
Pod undocumented
85  
86 # CGroups controllers Interface
87 2 ▶sub controllers { shift->_setget(+CONTROLLERS_INTERFACE() => pop) }
Subroutine controllers: called CC=1 SCAR=0.0
Pod undocumented
88  
89 # CGroups subtree_control Interface
90 2 ▶sub subtree_control { shift->_setget(+SUBTREE_CONTROL_INTERFACE() => pop) }
Subroutine subtree_control: called CC=1 SCAR=0.0
Pod undocumented
91  
92 # CGroups max.descendants Interface
93 2 ▶sub max_descendants { shift->_setget(+MAX_DESCENDANT_INTERFACE() => pop) }
Subroutine max_descendants: called CC=1 SCAR=0.0
Pod undocumented
94  
95 # CGroups max.depth Interface
96 2 ▶sub max_depths { shift->_setget(+MAX_DEPTH_INTERFACE() => pop) }
Subroutine max_depths: called CC=1 SCAR=0.0
Pod undocumented
97  
98 # CGroups stat Interface
99 1 ▶sub stat { shift->_list(+STAT_INTERFACE()) }
Subroutine stat: called CC=1 SCAR=0.0
Pod undocumented
100  
101 15 *IO = \&io;
102 15 *CPU = \&cpu;
103 15 *MEMORY = \&memory;
104 15 *PID = \&pid;
105 15 *RDMA = \&rdma;
106  
107 15 1;
108  
109 =encoding utf-8
110  
111 =head1 NAME
112  
113 Mojo::IOLoop::ReadWriteProcess::CGroup::v2 - CGroups v2 implementation.
114  
115 =head1 SYNOPSIS
116  
117 use Mojo::IOLoop::ReadWriteProcess::CGroup::v2;
118  
119 my $cgroup = Mojo::IOLoop::ReadWriteProcess::CGroup::v2->new( name => "test" );
120  
121 $cgroup->create;
122 $cgroup->exists;
123 my $child = $cgroup->child('bar');
124  
125 =head1 DESCRIPTION
126  
127 This module uses features that are only available on Linux,
128 and requires cgroups and capability for unshare syscalls to achieve pid isolation.
129  
130 =head1 METHODS
131  
132 L<Mojo::IOLoop::ReadWriteProcess::CGroup::v2> inherits all methods from L<Mojo::Base> and implements
133 the following new ones.
134  
135 =head1 LICENSE
136  
137 Copyright (C) Ettore Di Giacinto.
138  
139 This library is free software; you can redistribute it and/or modify
140 it under the same terms as Perl itself.
141  
142 =head1 AUTHOR
143  
144 Ettore Di Giacinto E<lt>edigiacinto@suse.comE<gt>
145  
146 =cut
« lib/Mojo/IOLoop/ReadWriteProcess/CGroup/v1/Memory.pm ↑ Summary