xs/ii.xs

filter: Statementstmt 95.6% 400 / 418 Branchbran 68.3% 581 / 850 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 77.3% 981 / 1268 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/ss.xs ↑ Summary Shared.xs »
1 MODULE = Data::HashMap::Shared PACKAGE = Data::HashMap::Shared::II
2 PROTOTYPES: DISABLE
3  
4 SV*
5 new(SV* class_sv, SV* path_sv, SV* max_entries_sv, SV* lru_max_sv = NULL, SV* ttl_default_sv = NULL, SV* lru_skip_sv = NULL, SV* arena_cap_sv = NULL, SV* file_mode_sv = NULL)
6 CODE:
7 43149 const char *class = shm_invocant_class(aTHX_ class_sv, "Data::HashMap::Shared::II");
8 43149 uint32_t max_entries = shm_u32_arg(aTHX_ max_entries_sv, "max_entries", "Data::HashMap::Shared::II", 0);
9 43142 uint32_t lru_max = shm_u32_arg(aTHX_ lru_max_sv, "lru_max", "Data::HashMap::Shared::II", 0);
10 43139 uint32_t ttl_default = shm_u32_arg(aTHX_ ttl_default_sv, "ttl_default", "Data::HashMap::Shared::II", 0);
11 43136 uint32_t lru_skip = shm_u32_arg(aTHX_ lru_skip_sv, "lru_skip", "Data::HashMap::Shared::II", 0);
12 43133 ▶ uint64_t arena_cap = arena_cap_sv ? shm_count_arg(aTHX_ arena_cap_sv, "arena_cap", "Data::HashMap::Shared::II") : 0;
Branch: 1 branch
BranchTrueFalseTotal
uint64_t arena_cap = arena_cap_sv ? shm_count_arg(aTHX_ arena_cap_sv, "arena_cap", "Data::HashMap::Shared::II") : 0; 12 43121 43133
13 43132 ▶ UV file_mode = file_mode_sv ? shm_count_arg(aTHX_ file_mode_sv, "file_mode", "Data::HashMap::Shared::II") : 0600;
Branch: 1 branch
BranchTrueFalseTotal
UV file_mode = file_mode_sv ? shm_count_arg(aTHX_ file_mode_sv, "file_mode", "Data::HashMap::Shared::II") : 0600; 10 43122 43132
14 43129 ▶ char errbuf[SHM_ERR_BUFLEN]; const char* path = SHM_WRITE_PATH_ARG(path_sv, "path", "Data::HashMap::Shared::II", "new"); ShmHandle* map = shm_ii_create(path, (uint32_t)max_entries, (uint32_t)lru_max, (uint32_t)ttl_default, (uint32_t)lru_skip, (uint64_t)arena_cap, shm_file_mode(aTHX_ file_mode, "Data::HashMap::Shared::II"), errbuf);
Branch: 3 branches
BranchTrueFalseTotal
char errbuf[SHM_ERR_BUFLEN]; const char* path = SHM_WRITE_PATH_ARG(path_sv, "path", "Data::HashMap::Shared::II", "new"); ShmHandle* map = shm_ii_create(path, (uint32_t)max_entries, (uint32_t)lru_max, (uint32_t)ttl_default, (uint32_t)lru_skip, (uint64_t)arena_cap, shm_file_mode(aTHX_ file_mode, "Data::HashMap::Shared::II"), errbuf); 6 43123 43129
char errbuf[SHM_ERR_BUFLEN]; const char* path = SHM_WRITE_PATH_ARG(path_sv, "path", "Data::HashMap::Shared::II", "new"); ShmHandle* map = shm_ii_create(path, (uint32_t)max_entries, (uint32_t)lru_max, (uint32_t)ttl_default, (uint32_t)lru_skip, (uint64_t)arena_cap, shm_file_mode(aTHX_ file_mode, "Data::HashMap::Shared::II"), errbuf); 0 6 6
char errbuf[SHM_ERR_BUFLEN]; const char* path = SHM_WRITE_PATH_ARG(path_sv, "path", "Data::HashMap::Shared::II", "new"); ShmHandle* map = shm_ii_create(path, (uint32_t)max_entries, (uint32_t)lru_max, (uint32_t)ttl_default, (uint32_t)lru_skip, (uint64_t)arena_cap, shm_file_mode(aTHX_ file_mode, "Data::HashMap::Shared::II"), errbuf); 43043 86 43129
15 43120 ▶ if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error");
Branch: 2 branches
BranchTrueFalseTotal
if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error"); 36 43084 43120
if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error"); 36 0 36
16 43084 ▶ SHM_RETURN_MAP(map, "Data::HashMap::Shared::II", class);
Branch: 2 branches
BranchTrueFalseTotal
SHM_RETURN_MAP(map, "Data::HashMap::Shared::II", class); 0 43084 43084
SHM_RETURN_MAP(map, "Data::HashMap::Shared::II", class); 9 43075 43084
17 OUTPUT:
18 RETVAL
19  
20 SV*
21 new_sharded(SV* class_sv, SV* path_prefix_sv, SV* num_shards_sv, SV* max_entries_sv, SV* lru_max_sv = NULL, SV* ttl_default_sv = NULL, SV* lru_skip_sv = NULL, SV* arena_cap_sv = NULL, SV* file_mode_sv = NULL)
22 CODE:
23 67 const char *class = shm_invocant_class(aTHX_ class_sv, "Data::HashMap::Shared::II");
24 67 ▶ const char* path_prefix = SHM_WRITE_PATH_ARG(path_prefix_sv, "path prefix", "Data::HashMap::Shared::II", "new_sharded");
Branch: 3 branches
BranchTrueFalseTotal
const char* path_prefix = SHM_WRITE_PATH_ARG(path_prefix_sv, "path prefix", "Data::HashMap::Shared::II", "new_sharded"); 2 65 67
const char* path_prefix = SHM_WRITE_PATH_ARG(path_prefix_sv, "path prefix", "Data::HashMap::Shared::II", "new_sharded"); 0 2 2
const char* path_prefix = SHM_WRITE_PATH_ARG(path_prefix_sv, "path prefix", "Data::HashMap::Shared::II", "new_sharded"); 66 1 67
25 65 uint32_t max_entries = shm_u32_arg(aTHX_ max_entries_sv, "max_entries", "Data::HashMap::Shared::II", 0);
26 64 uint32_t lru_max = shm_u32_arg(aTHX_ lru_max_sv, "lru_max", "Data::HashMap::Shared::II", 0);
27 63 uint32_t ttl_default = shm_u32_arg(aTHX_ ttl_default_sv, "ttl_default", "Data::HashMap::Shared::II", 0);
28 62 uint32_t lru_skip = shm_u32_arg(aTHX_ lru_skip_sv, "lru_skip", "Data::HashMap::Shared::II", 0);
29 61 ▶ uint64_t arena_cap = arena_cap_sv ? shm_count_arg(aTHX_ arena_cap_sv, "arena_cap", "Data::HashMap::Shared::II") : 0;
Branch: 1 branch
BranchTrueFalseTotal
uint64_t arena_cap = arena_cap_sv ? shm_count_arg(aTHX_ arena_cap_sv, "arena_cap", "Data::HashMap::Shared::II") : 0; 1 60 61
30 61 ▶ UV file_mode = file_mode_sv ? shm_count_arg(aTHX_ file_mode_sv, "file_mode", "Data::HashMap::Shared::II") : 0600;
Branch: 1 branch
BranchTrueFalseTotal
UV file_mode = file_mode_sv ? shm_count_arg(aTHX_ file_mode_sv, "file_mode", "Data::HashMap::Shared::II") : 0600; 1 60 61
31 60 uint32_t num_shards = shm_u32_arg(aTHX_ num_shards_sv, "num_shards", "Data::HashMap::Shared::II", 0);
32 57 char errbuf[SHM_ERR_BUFLEN]; ShmHandle* map = shm_ii_create_sharded(path_prefix, (uint32_t)num_shards, (uint32_t)max_entries, (uint32_t)lru_max, (uint32_t)ttl_default, (uint32_t)lru_skip, (uint64_t)arena_cap, shm_file_mode(aTHX_ file_mode, "Data::HashMap::Shared::II"), errbuf);
33 57 ▶ if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error");
Branch: 2 branches
BranchTrueFalseTotal
if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error"); 12 45 57
if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error"); 12 0 12
34 45 ▶ SHM_RETURN_MAP(map, "Data::HashMap::Shared::II", class);
Branch: 2 branches
BranchTrueFalseTotal
SHM_RETURN_MAP(map, "Data::HashMap::Shared::II", class); 45 0 45
SHM_RETURN_MAP(map, "Data::HashMap::Shared::II", class); 1 44 45
35 OUTPUT:
36 RETVAL
37  
38  
39 SV*
40 new_memfd(SV* class_sv, SV* name_sv, SV* max_entries_sv, SV* lru_max_sv = NULL, SV* ttl_default_sv = NULL, SV* lru_skip_sv = NULL, SV* arena_cap_sv = NULL)
41 CODE:
42 14 const char *class = shm_invocant_class(aTHX_ class_sv, "Data::HashMap::Shared::II");
43 char errbuf[SHM_ERR_BUFLEN];
44 14 ▶ const char* name = SHM_PATH_ARG(name_sv, "name", "Data::HashMap::Shared::II");
Branch: 3 branches
BranchTrueFalseTotal
const char* name = SHM_PATH_ARG(name_sv, "name", "Data::HashMap::Shared::II"); 2 12 14
const char* name = SHM_PATH_ARG(name_sv, "name", "Data::HashMap::Shared::II"); 0 2 2
const char* name = SHM_PATH_ARG(name_sv, "name", "Data::HashMap::Shared::II"); 13 1 14
45 13 uint32_t max_entries = shm_u32_arg(aTHX_ max_entries_sv, "max_entries", "Data::HashMap::Shared::II", 0);
46 12 uint32_t lru_max = shm_u32_arg(aTHX_ lru_max_sv, "lru_max", "Data::HashMap::Shared::II", 0);
47 11 uint32_t ttl_default = shm_u32_arg(aTHX_ ttl_default_sv, "ttl_default", "Data::HashMap::Shared::II", 0);
48 10 uint32_t lru_skip = shm_u32_arg(aTHX_ lru_skip_sv, "lru_skip", "Data::HashMap::Shared::II", 0);
49 9 ▶ uint64_t arena_cap = arena_cap_sv ? shm_count_arg(aTHX_ arena_cap_sv, "arena_cap", "Data::HashMap::Shared::II") : 0;
Branch: 1 branch
BranchTrueFalseTotal
uint64_t arena_cap = arena_cap_sv ? shm_count_arg(aTHX_ arena_cap_sv, "arena_cap", "Data::HashMap::Shared::II") : 0; 0 9 9
50 9 ShmHandle* map = shm_ii_create_memfd(name, (uint32_t)max_entries, (uint32_t)lru_max, (uint32_t)ttl_default, (uint32_t)lru_skip, (uint64_t)arena_cap, errbuf);
51 9 ▶ if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error");
Branch: 2 branches
BranchTrueFalseTotal
if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error"); 0 9 9
if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error"); 0 0 0
52 9 ▶ SHM_RETURN_MAP(map, "Data::HashMap::Shared::II", class);
Branch: 2 branches
BranchTrueFalseTotal
SHM_RETURN_MAP(map, "Data::HashMap::Shared::II", class); 0 9 9
SHM_RETURN_MAP(map, "Data::HashMap::Shared::II", class); 1 8 9
53 OUTPUT:
54 RETVAL
55  
56 SV*
57 new_from_fd(SV* class_sv, int fd)
58 CODE:
59 10 const char *class = shm_invocant_class(aTHX_ class_sv, "Data::HashMap::Shared::II");
60 char errbuf[SHM_ERR_BUFLEN];
61 10 ▶ SHM_TAINT_CHECK("Data::HashMap::Shared::II->new_from_fd");
Branch: 1 branch
BranchTrueFalseTotal
SHM_TAINT_CHECK("Data::HashMap::Shared::II->new_from_fd"); 4 6 10
62 9 ShmHandle* map = shm_ii_open_fd(fd, errbuf);
63 9 ▶ if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error");
Branch: 2 branches
BranchTrueFalseTotal
if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error"); 4 5 9
if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error"); 4 0 4
64 5 ▶ SHM_RETURN_MAP(map, "Data::HashMap::Shared::II", class);
Branch: 2 branches
BranchTrueFalseTotal
SHM_RETURN_MAP(map, "Data::HashMap::Shared::II", class); 0 5 5
SHM_RETURN_MAP(map, "Data::HashMap::Shared::II", class); 0 5 5
65 OUTPUT:
66 RETVAL
67  
68 SV*
69 new_readonly(SV* class_sv, SV* path_sv)
70 CODE:
71 39 const char *class = shm_invocant_class(aTHX_ class_sv, "Data::HashMap::Shared::II");
72 char errbuf[SHM_ERR_BUFLEN];
73 39 ▶ const char* path = SHM_PATH_ARG(path_sv, "path", "Data::HashMap::Shared::II");
Branch: 3 branches
BranchTrueFalseTotal
const char* path = SHM_PATH_ARG(path_sv, "path", "Data::HashMap::Shared::II"); 6 33 39
const char* path = SHM_PATH_ARG(path_sv, "path", "Data::HashMap::Shared::II"); 0 6 6
const char* path = SHM_PATH_ARG(path_sv, "path", "Data::HashMap::Shared::II"); 37 2 39
74 38 ▶ if (!path) croak("Data::HashMap::Shared::II->new_readonly: path is required");
Branch: 1 branch
BranchTrueFalseTotal
if (!path) croak("Data::HashMap::Shared::II->new_readonly: path is required"); 2 36 38
75 36 ShmHandle* map = shm_ii_open_readonly(path, errbuf);
76 36 ▶ if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error");
Branch: 2 branches
BranchTrueFalseTotal
if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error"); 14 22 36
if (!map) croak("Data::HashMap::Shared::II: %s", errbuf[0] ? errbuf : "unknown error"); 14 0 14
77 22 RETVAL = sv_setref_pv(newSV(0), class, (void*)map);
78 OUTPUT:
79 RETVAL
80  
81 void
82 freeze(SV* self_sv)
83 CODE:
84 27 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 27 27
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 27 27
85 27 ▶ if (h->readonly || shm_is_fully_sealed(h)) croak("Data::HashMap::Shared::II->freeze: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_fully_sealed(h)) croak("Data::HashMap::Shared::II->freeze: map is frozen (read-only)"); 25 2 27
if (h->readonly || shm_is_fully_sealed(h)) croak("Data::HashMap::Shared::II->freeze: map is frozen (read-only)"); 2 23 25
86 23 ▶ if (shm_freeze(h) != 0) croak("Data::HashMap::Shared::II->freeze: msync: %s", strerror(errno));
Branch: 1 branch
BranchTrueFalseTotal
if (shm_freeze(h) != 0) croak("Data::HashMap::Shared::II->freeze: msync: %s", strerror(errno)); 0 23 23
87 23 shm_mark_readonly(h);
88  
89 UV
90 frozen(SV* self_sv)
91 CODE:
92 6 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 6 6
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 6 6
93 6 ▶ RETVAL = (UV)shm_is_sealed(h);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)shm_is_sealed(h); 0 6 6
94 OUTPUT:
95 RETVAL
96  
97 UV
98 readonly(SV* self_sv)
99 CODE:
100 8 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 8 8
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 8 8
101 8 ▶ RETVAL = (UV)(h->readonly ? 1 : 0);
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = (UV)(h->readonly ? 1 : 0); 5 3 8
RETVAL = (UV)(h->readonly ? 1 : 0); 2 6 8
102 OUTPUT:
103 RETVAL
104  
105 IV
106 memfd(SV* self_sv)
107 CODE:
108 8 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 8 8
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 8 8
109 8 ▶ RETVAL = h->backing_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->backing_fd; 0 8 8
110 OUTPUT:
111 RETVAL
112  
113  
114 void
115 sync(SV* self_sv)
116 CODE:
117 2 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 2 2
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 2 2
118 2 ▶ if (shm_msync(h) != 0) croak("Data::HashMap::Shared::II->sync: %s", strerror(errno));
Branch: 1 branch
BranchTrueFalseTotal
if (shm_msync(h) != 0) croak("Data::HashMap::Shared::II->sync: %s", strerror(errno)); 0 2 2
119  
120 void
121 DESTROY(SV* self_sv)
122 CODE:
123 43165 ▶ if (!sv_isobject(self_sv) || !sv_derived_from(self_sv, "Data::HashMap::Shared::II")) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!sv_isobject(self_sv) || !sv_derived_from(self_sv, "Data::HashMap::Shared::II")) return; 43165 0 43165
if (!sv_isobject(self_sv) || !sv_derived_from(self_sv, "Data::HashMap::Shared::II")) return; 0 43165 43165
124 43165 ShmHandle* h = INT2PTR(ShmHandle*, SvIV(SvRV(self_sv)));
125 43165 ▶ if (!h) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!h) return; 0 43165 43165
126 43165 sv_setiv(SvRV(self_sv), 0);
127 43165 shm_close_map(h);
128  
129 bool
130 put(SV* self_sv, int64_t key, int64_t value)
131 CODE:
132 163736 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 9 163727 163736
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 163727 163727
133 163727 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 163725 2 163727
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 4 163721 163725
134 163721 ▶ RETVAL = shm_ii_put(h, key, value);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = shm_ii_put(h, key, value); 163554 167 163721
135 OUTPUT:
136 RETVAL
137  
138 UV
139 set_multi(SV* self_sv, ...)
140 CODE:
141 5 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 5 5
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 5 5
142 5 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 4 1 5
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 3 4
143 3 ▶ if ((items - 1) % 2 != 0) croak("%s: set_multi requires an even number of arguments (key, value pairs)", shm_class);
Branch: 1 branch
BranchTrueFalseTotal
if ((items - 1) % 2 != 0) croak("%s: set_multi requires an even number of arguments (key, value pairs)", shm_class); 1 2 3
144 2 uint32_t count = 0;
145 2 ▶ if (h->shard_handles) {
Branch: 1 branch
BranchTrueFalseTotal
if (h->shard_handles) { 0 2 2
146 0 ▶ for (int i = 1; i < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (int i = 1; i < items; i += 2) { 0 0 0
147 0 int64_t _k = (int64_t)SvIV(ST(i));
148 0 int64_t _v = (int64_t)SvIV(ST(i + 1));
149 0 ▶ REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 0 0
REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 0 0
150 0 count += shm_ii_put(h, _k, _v);
151 }
152 } else {
153 /* Materialize arguments before the lock: a re-entrant FETCH would self-deadlock. */
154 2 int _n = (items - 1) / 2;
155 int64_t *_ks, *_vs;
156 2 ▶ Newx(_ks, _n ? _n : 1, int64_t); SAVEFREEPV(_ks);
Branch: 1 branch
BranchTrueFalseTotal
Newx(_ks, _n ? _n : 1, int64_t); SAVEFREEPV(_ks); 2 0 2
157 2 ▶ Newx(_vs, _n ? _n : 1, int64_t); SAVEFREEPV(_vs);
Branch: 1 branch
BranchTrueFalseTotal
Newx(_vs, _n ? _n : 1, int64_t); SAVEFREEPV(_vs); 2 0 2
158 24 ▶ for (int i = 1, j = 0; i < items; i += 2, j++) {
Branch: 1 branch
BranchTrueFalseTotal
for (int i = 1, j = 0; i < items; i += 2, j++) { 22 2 24
159 22 _ks[j] = (int64_t)SvIV(ST(i));
160 22 _vs[j] = (int64_t)SvIV(ST(i + 1));
161 }
162 2 ▶ REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 2 2
REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 2 2
163 2 WRSEQ_BEGIN(h);
164 24 ▶ for (int j = 0; j < _n; j++, shm_sig_check_every(h, (uint32_t)j, SHM_SIG_CHECK_ENTRIES))
Branch: 1 branch
BranchTrueFalseTotal
for (int j = 0; j < _n; j++, shm_sig_check_every(h, (uint32_t)j, SHM_SIG_CHECK_ENTRIES)) 22 2 24
165 22 count += shm_ii_put_inner(h, _ks[j], _vs[j], SHM_TTL_USE_DEFAULT);
166 2 WRSEQ_END(h);
167 }
168 2 ▶ RETVAL = count;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = count; 0 2 2
169 OUTPUT:
170 RETVAL
171  
172 UV
173 remove_multi(SV* self_sv, ...)
174 CODE:
175 5 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 5 5
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 5 5
176 5 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 4 1 5
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 3 4
177 3 uint32_t count = 0;
178 3 ▶ if (h->shard_handles) {
Branch: 1 branch
BranchTrueFalseTotal
if (h->shard_handles) { 0 3 3
179 0 ▶ for (int i = 1; i < items; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (int i = 1; i < items; i++) { 0 0 0
180 0 int64_t _k = (int64_t)SvIV(ST(i));
181 0 ▶ REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 0 0
REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 0 0
182 0 count += shm_ii_remove(h, _k);
183 }
184 } else {
185 3 int _n = items - 1;
186 int64_t *_ks;
187 3 ▶ Newx(_ks, _n ? _n : 1, int64_t); SAVEFREEPV(_ks);
Branch: 1 branch
BranchTrueFalseTotal
Newx(_ks, _n ? _n : 1, int64_t); SAVEFREEPV(_ks); 2 1 3
188 20006 ▶ for (int i = 1, j = 0; i < items; i++, j++)
Branch: 1 branch
BranchTrueFalseTotal
for (int i = 1, j = 0; i < items; i++, j++) 20003 3 20006
189 20003 _ks[j] = (int64_t)SvIV(ST(i)); /* FETCH before the lock */
190 3 ▶ REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 3 3
REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 3 3
191 3 WRSEQ_BEGIN(h);
192 20006 ▶ for (int j = 0; j < _n; j++, shm_sig_check_every(h, (uint32_t)j, SHM_SIG_CHECK_ENTRIES))
Branch: 1 branch
BranchTrueFalseTotal
for (int j = 0; j < _n; j++, shm_sig_check_every(h, (uint32_t)j, SHM_SIG_CHECK_ENTRIES)) 20003 3 20006
193 20003 count += shm_ii_remove_inner(h, _ks[j]);
194 3 ▶ if (count) shm_ii_maybe_shrink(h);
Branch: 1 branch
BranchTrueFalseTotal
if (count) shm_ii_maybe_shrink(h); 2 1 3
195 3 WRSEQ_END(h);
196 }
197 3 ▶ RETVAL = count;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = count; 0 3 3
198 OUTPUT:
199 RETVAL
200  
201 void
202 get_multi(SV* self_sv, ...)
203 PPCODE:
204 104055 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 104055 104055
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 104055 104055
205 104055 int nkeys = items - 1;
206 104055 ▶ if (nkeys == 0) XSRETURN_EMPTY;
Branch: 1 branch
BranchTrueFalseTotal
if (nkeys == 0) XSRETURN_EMPTY; 0 104055 104055
207 104055 ▶ EXTEND(SP, nkeys);
Branch: 2 branches
BranchTrueFalseTotal
EXTEND(SP, nkeys); 104055 0 104055
EXTEND(SP, nkeys); 0 104055 104055
208 104055 ▶ if (h->shard_handles) {
Branch: 1 branch
BranchTrueFalseTotal
if (h->shard_handles) { 52005 52050 104055
209 1716043 ▶ for (int i = 0; i < nkeys; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (int i = 0; i < nkeys; i++) { 1664038 52005 1716043
210 1664038 int64_t key = (int64_t)SvIV(ST(i + 1));
211 int64_t val;
212 1664038 ▶ REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 1664038 1664038
REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 1664038 1664038
213 1664038 ▶ if (shm_ii_get(h, key, &val))
Branch: 1 branch
BranchTrueFalseTotal
if (shm_ii_get(h, key, &val)) 1664037 1 1664038
214 1664037 mPUSHi(val);
215 else
216 1 PUSHs(&PL_sv_undef);
217 }
218 } else {
219 52050 ShmHeader *hdr = h->hdr;
220 52050 ShmNodeII *nodes = (ShmNodeII *)h->nodes;
221 52050 uint8_t *states = h->states;
222 52050 uint32_t *hashes = NULL;
223 52050 Newx(hashes, nkeys, uint32_t);
224 52050 SAVEFREEPV(hashes);
225 52050 int64_t *keys = NULL; /* read once: a tied key's second FETCH may differ */
226 52050 Newx(keys, nkeys, int64_t);
227 52050 SAVEFREEPV(keys);
228 1716133 ▶ for (int i = 0; i < nkeys; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (int i = 0; i < nkeys; i++) 1664083 52050 1716133
229 1664083 keys[i] = (int64_t)SvIV(ST(i + 1)); /* FETCH the keys before the lock */
230 52050 ▶ REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 52050 52050
REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 52050 52050
231 52050 RDLOCK_GUARD(h);
232 52050 ▶ uint32_t now = h->expires_at ? shm_now() : 0;
Branch: 1 branch
BranchTrueFalseTotal
uint32_t now = h->expires_at ? shm_now() : 0; 46 52004 52050
233 52050 uint32_t mask = hdr->table_cap - 1;
234 1716133 ▶ for (int i = 0; i < nkeys; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (int i = 0; i < nkeys; i++) { 1664083 52050 1716133
235 1664083 hashes[i] = shm_hash_int64(keys[i]);
236 1664083 __builtin_prefetch(&states[hashes[i] & mask], 0, 0);
237 1664083 __builtin_prefetch(&nodes[hashes[i] & mask], 0, 0);
238 }
239 52050 ▶ REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 52050 52050
REEXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 52050 52050
240 1716133 ▶ for (int i = 0; i < nkeys; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (int i = 0; i < nkeys; i++) { 1664083 52050 1716133
241 1664083 int64_t key = keys[i];
242 1664083 uint32_t hash = hashes[i];
243 1664083 uint32_t pos = hash & mask;
244 1664083 uint8_t tag = SHM_MAKE_TAG(hash);
245 1664083 int found = 0;
246 1664083 uint32_t fidx = 0;
247 1664083 int64_t val = 0;
248 2600101 ▶ for (uint32_t j = 0; j <= mask; j++) {
Branch: 1 branch
BranchTrueFalseTotal
for (uint32_t j = 0; j <= mask; j++) { 2600101 0 2600101
249 2600101 uint32_t idx = (pos + j) & mask;
250 2600101 uint8_t st = states[idx];
251 2600101 ▶ if (st == SHM_EMPTY) break;
Branch: 1 branch
BranchTrueFalseTotal
if (st == SHM_EMPTY) break; 0 2600101 2600101
252 2600101 ▶ if (st != tag) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (st != tag) continue; 936018 1664083 2600101
253 1664083 ▶ if (nodes[idx].key == key) {
Branch: 1 branch
BranchTrueFalseTotal
if (nodes[idx].key == key) { 1664083 0 1664083
254 1664083 ▶ if (h->expires_at && h->expires_at[idx] && now >= h->expires_at[idx]) break;
Branch: 3 branches
BranchTrueFalseTotal
if (h->expires_at && h->expires_at[idx] && now >= h->expires_at[idx]) break; 47 1664036 1664083
if (h->expires_at && h->expires_at[idx] && now >= h->expires_at[idx]) break; 45 2 47
if (h->expires_at && h->expires_at[idx] && now >= h->expires_at[idx]) break; 32 13 45
255 1664051 val = __atomic_load_n(&nodes[idx].value, __ATOMIC_RELAXED);
256 1664051 fidx = idx;
257 1664051 found = 1;
258 1664051 break;
259 }
260 }
261 1664083 ▶ if (found) {
Branch: 1 branch
BranchTrueFalseTotal
if (found) { 1664051 32 1664083
262 1664051 shm_lru_mark(h, fidx);
263 1664051 mPUSHi(val);
264 32 } else PUSHs(&PL_sv_undef);
265 1664083 ▶ if (i + 1 < nkeys) {
Branch: 1 branch
BranchTrueFalseTotal
if (i + 1 < nkeys) { 1612033 52050 1664083
266 1612033 uint32_t npos = hashes[i + 1] & mask;
267 1612033 __builtin_prefetch(&states[npos], 0, 0);
268 1612033 __builtin_prefetch(&nodes[npos], 0, 0);
269 }
270 }
271 }
272  
273 void
274 get_with_ttl(SV* self_sv, int64_t key)
275 PPCODE:
276 54 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 54 54
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 54 54
277 int64_t out_value;
278 int64_t out_ttl;
279 54 ▶ if (!shm_ii_get_with_ttl(h, key, &out_value, &out_ttl)) XSRETURN_EMPTY;
Branch: 1 branch
BranchTrueFalseTotal
if (!shm_ii_get_with_ttl(h, key, &out_value, &out_ttl)) XSRETURN_EMPTY; 34 20 54
280 20 ▶ EXTEND(SP, 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 2); 0 20 20
281 20 mPUSHi(out_value);
282 20 ▶ if (out_ttl < 0) PUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
if (out_ttl < 0) PUSHs(&PL_sv_undef); 4 16 20
283 16 else mPUSHi(out_ttl);
284  
285 SV*
286 stats(SV* self_sv)
287 CODE:
288 8 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 8 8
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 8 8
289 8 HV *hv = newHV();
290 8 hv_store(hv, "size", 4, newSVuv(shm_ii_size(h)), 0);
291 8 hv_store(hv, "capacity", 8, newSVuv(shm_ii_capacity(h)), 0);
292 8 hv_store(hv, "max_entries", 11, newSVuv(shm_ii_max_entries(h)), 0);
293 8 hv_store(hv, "tombstones", 10, newSVuv(shm_ii_tombstones(h)), 0);
294 8 hv_store(hv, "mmap_size", 9, newSVuv(shm_ii_mmap_size(h)), 0);
295 8 hv_store(hv, "arena_used", 10, newSVuv(shm_ii_arena_used(h)), 0);
296 8 hv_store(hv, "arena_cap", 9, newSVuv(shm_ii_arena_cap(h)), 0);
297 8 hv_store(hv, "evictions", 9, newSVuv(shm_ii_stat_evictions(h)), 0);
298 8 hv_store(hv, "expired", 7, newSVuv(shm_ii_stat_expired(h)), 0);
299 8 hv_store(hv, "recoveries", 10, newSVuv(shm_ii_stat_recoveries(h)), 0);
300 8 hv_store(hv, "max_size", 8, newSVuv(shm_ii_max_size(h)), 0);
301 8 hv_store(hv, "ttl", 3, newSVuv(shm_ii_ttl(h)), 0);
302 8 hv_store(hv, "frozen", 6, newSVuv((UV)shm_is_sealed(h)), 0);
303 8 ▶ hv_store(hv, "readonly", 8, newSVuv((UV)(h->readonly ? 1 : 0)), 0);
Branch: 1 branch
BranchTrueFalseTotal
hv_store(hv, "readonly", 8, newSVuv((UV)(h->readonly ? 1 : 0)), 0); 1 7 8
304 8 RETVAL = newRV_noinc((SV*)hv);
305 OUTPUT:
306 RETVAL
307  
308 bool
309 cas(SV* self_sv, int64_t key, int64_t expected, int64_t desired)
310 CODE:
311 3 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 3 3
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 3 3
312 3 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 2 1 3
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 1 2
313 1 ▶ RETVAL = shm_ii_cas(h, key, expected, desired);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = shm_ii_cas(h, key, expected, desired); 1 0 1
314 OUTPUT:
315 RETVAL
316  
317 SV*
318 cas_take(SV* self_sv, int64_t key, int64_t expected)
319 CODE:
320 6 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 6 6
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 6 6
321 6 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 5 1 6
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 4 5
322 int64_t out_value;
323 4 ▶ if (!shm_ii_cas_take(h, key, expected, &out_value)) XSRETURN_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if (!shm_ii_cas_take(h, key, expected, &out_value)) XSRETURN_UNDEF; 2 2 4
324 2 RETVAL = newSViv(out_value);
325 OUTPUT:
326 RETVAL
327  
328 bool
329 persist(SV* self_sv, int64_t key)
330 CODE:
331 2 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 2 2
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 2 2
332 2 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 1 2
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 0 1
333 0 ▶ RETVAL = shm_ii_persist(h, key);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = shm_ii_persist(h, key); 0 0 0
334 OUTPUT:
335 RETVAL
336  
337 bool
338 set_ttl(SV* self_sv, int64_t key, SV* ttl_sec_sv)
339 CODE:
340 37 uint32_t ttl_sec = shm_u32_arg(aTHX_ ttl_sec_sv, "ttl", "Data::HashMap::Shared::II", 0);
341 34 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 34 34
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 34 34
342 34 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 33 1 34
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 32 33
343 32 ▶ RETVAL = shm_ii_set_ttl(h, key, (uint32_t)ttl_sec);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = shm_ii_set_ttl(h, key, (uint32_t)ttl_sec); 32 0 32
344 OUTPUT:
345 RETVAL
346  
347 SV*
348 get(SV* self_sv, int64_t key)
349 CODE:
350 51374 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 10 51364 51374
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 51364 51364
351 int64_t value;
352 51364 ▶ if (!shm_ii_get(h, key, &value)) XSRETURN_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if (!shm_ii_get(h, key, &value)) XSRETURN_UNDEF; 4324 47040 51364
353 47040 RETVAL = newSViv(value);
354 OUTPUT:
355 RETVAL
356  
357 bool
358 remove(SV* self_sv, int64_t key)
359 CODE:
360 40778 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 40778 40778
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 40778 40778
361 40778 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 40776 2 40778
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 40775 40776
362 40775 ▶ RETVAL = shm_ii_remove(h, key);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = shm_ii_remove(h, key); 39527 1248 40775
363 OUTPUT:
364 RETVAL
365  
366 bool
367 exists(SV* self_sv, int64_t key)
368 CODE:
369 1722 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 1722 1722
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 1722 1722
370 1722 ▶ RETVAL = shm_ii_exists(h, key);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = shm_ii_exists(h, key); 1281 441 1722
371 OUTPUT:
372 RETVAL
373  
374 SV*
375 incr(SV* self_sv, int64_t key)
376 CODE:
377 24 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 24 24
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 24 24
378 24 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 22 2 24
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 21 22
379 int ok;
380 21 int64_t val = shm_ii_incr_by(h, key, 1, &ok);
381 21 ▶ if (!ok) croak("Data::HashMap::Shared::II: increment failed: no room for a new key");
Branch: 1 branch
BranchTrueFalseTotal
if (!ok) croak("Data::HashMap::Shared::II: increment failed: no room for a new key"); 2 19 21
382 19 RETVAL = newSViv(val);
383 OUTPUT:
384 RETVAL
385  
386 SV*
387 decr(SV* self_sv, int64_t key)
388 CODE:
389 6 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 6 6
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 6 6
390 6 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 4 2 6
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 3 4
391 int ok;
392 3 int64_t val = shm_ii_incr_by(h, key, -1, &ok);
393 3 ▶ if (!ok) croak("Data::HashMap::Shared::II: decrement failed: no room for a new key");
Branch: 1 branch
BranchTrueFalseTotal
if (!ok) croak("Data::HashMap::Shared::II: decrement failed: no room for a new key"); 2 1 3
394 1 RETVAL = newSViv(val);
395 OUTPUT:
396 RETVAL
397  
398 SV*
399 incr_by(SV* self_sv, int64_t key, int64_t delta)
400 CODE:
401 4774 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 4774 4774
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 4774 4774
402 4774 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 4772 2 4774
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 4771 4772
403 int ok;
404 4771 int64_t val = shm_ii_incr_by(h, key, delta, &ok);
405 4771 ▶ if (!ok) croak("Data::HashMap::Shared::II: incr_by failed: no room for a new key");
Branch: 1 branch
BranchTrueFalseTotal
if (!ok) croak("Data::HashMap::Shared::II: incr_by failed: no room for a new key"); 2 4769 4771
406 4769 RETVAL = newSViv(val);
407 OUTPUT:
408 RETVAL
409  
410 SV*
411 max(SV* self_sv, int64_t key, int64_t desired)
412 CODE:
413 4824 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 4824 4824
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 4824 4824
414 4824 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 4822 2 4824
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 4821 4822
415 int ok;
416 4821 int64_t val = shm_ii_set_minmax(h, key, desired, 1, &ok);
417 4821 ▶ if (!ok) croak("Data::HashMap::Shared::II: max failed: no room for a new key");
Branch: 1 branch
BranchTrueFalseTotal
if (!ok) croak("Data::HashMap::Shared::II: max failed: no room for a new key"); 2 4819 4821
418 4819 RETVAL = newSViv(val);
419 OUTPUT:
420 RETVAL
421  
422 SV*
423 min(SV* self_sv, int64_t key, int64_t desired)
424 CODE:
425 8 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 8 8
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 8 8
426 8 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 6 2 8
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 5 6
427 int ok;
428 5 int64_t val = shm_ii_set_minmax(h, key, desired, 0, &ok);
429 5 ▶ if (!ok) croak("Data::HashMap::Shared::II: min failed: no room for a new key");
Branch: 1 branch
BranchTrueFalseTotal
if (!ok) croak("Data::HashMap::Shared::II: min failed: no room for a new key"); 2 3 5
430 3 RETVAL = newSViv(val);
431 OUTPUT:
432 RETVAL
433  
434 UV
435 size(SV* self_sv)
436 CODE:
437 122 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 10 112 122
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 112 112
438 112 RETVAL = (UV)shm_ii_size(h);
439 OUTPUT:
440 RETVAL
441  
442 UV
443 max_entries(SV* self_sv)
444 CODE:
445 10 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 10 10
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 10 10
446 10 RETVAL = (UV)shm_ii_max_entries(h);
447 OUTPUT:
448 RETVAL
449  
450 void
451 keys(SV* self_sv)
452 PPCODE:
453 66 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 66 66
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 66 66
454 177824 ▶ SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key));
Branch: 15 branches
BranchTrueFalseTotal
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 5 61 66
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 1097 61 1158
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 51 1107 1158
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 0 1158 1158
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 0 1158 1158
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 0 0 0
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 0 0 0
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 0 0 0
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 23662 152938 176600
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 194 23468 23662
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 134 60 194
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 101 33 134
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 177353 405 177758
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 176600 753 177353
SHM_LIST_COPIES(ShmNodeII, 1, 0, SHM_COPY_INT(nodes[i].key)); 1158 66 1224
455  
456 void
457 values(SV* self_sv)
458 PPCODE:
459 5 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 5 5
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 5 5
460 2204 ▶ SHM_LIST_COPIES(ShmNodeII, 1, 0,
Branch: 15 branches
BranchTrueFalseTotal
SHM_LIST_COPIES(ShmNodeII, 1, 0, 1 4 5
SHM_LIST_COPIES(ShmNodeII, 1, 0, 4 4 8
SHM_LIST_COPIES(ShmNodeII, 1, 0, 5 3 8
SHM_LIST_COPIES(ShmNodeII, 1, 0, 0 8 8
SHM_LIST_COPIES(ShmNodeII, 1, 0, 0 8 8
SHM_LIST_COPIES(ShmNodeII, 1, 0, 0 0 0
SHM_LIST_COPIES(ShmNodeII, 1, 0, 0 0 0
SHM_LIST_COPIES(ShmNodeII, 1, 0, 0 0 0
SHM_LIST_COPIES(ShmNodeII, 1, 0, 1095 1096 2191
SHM_LIST_COPIES(ShmNodeII, 1, 0, 90 1005 1095
SHM_LIST_COPIES(ShmNodeII, 1, 0, 90 0 90
SHM_LIST_COPIES(ShmNodeII, 1, 0, 88 2 90
SHM_LIST_COPIES(ShmNodeII, 1, 0, 2193 6 2199
SHM_LIST_COPIES(ShmNodeII, 1, 0, 2191 2 2193
SHM_LIST_COPIES(ShmNodeII, 1, 0, 8 5 13
461 SHM_COPY_INT(__atomic_load_n(&nodes[i].value, __ATOMIC_RELAXED)));
462  
463 void
464 items(SV* self_sv)
465 PPCODE:
466 5 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 5 5
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 5 5
467 2204 ▶ SHM_LIST_COPIES(ShmNodeII, 2, 0,
Branch: 15 branches
BranchTrueFalseTotal
SHM_LIST_COPIES(ShmNodeII, 2, 0, 1 4 5
SHM_LIST_COPIES(ShmNodeII, 2, 0, 4 4 8
SHM_LIST_COPIES(ShmNodeII, 2, 0, 5 3 8
SHM_LIST_COPIES(ShmNodeII, 2, 0, 0 8 8
SHM_LIST_COPIES(ShmNodeII, 2, 0, 0 8 8
SHM_LIST_COPIES(ShmNodeII, 2, 0, 0 0 0
SHM_LIST_COPIES(ShmNodeII, 2, 0, 0 0 0
SHM_LIST_COPIES(ShmNodeII, 2, 0, 0 0 0
SHM_LIST_COPIES(ShmNodeII, 2, 0, 1095 1096 2191
SHM_LIST_COPIES(ShmNodeII, 2, 0, 90 1005 1095
SHM_LIST_COPIES(ShmNodeII, 2, 0, 90 0 90
SHM_LIST_COPIES(ShmNodeII, 2, 0, 88 2 90
SHM_LIST_COPIES(ShmNodeII, 2, 0, 2193 6 2199
SHM_LIST_COPIES(ShmNodeII, 2, 0, 2191 2 2193
SHM_LIST_COPIES(ShmNodeII, 2, 0, 8 5 13
468 SHM_COPY_INT(nodes[i].key);
469 SHM_COPY_INT(__atomic_load_n(&nodes[i].value, __ATOMIC_RELAXED)));
470  
471  
472 void
473 each(SV* self_sv)
474 PPCODE:
475 17480 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 17480 17480
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 17480 17480
476 int64_t out_key, out_value;
477 17480 ▶ if (shm_ii_each(h, &out_key, &out_value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (shm_ii_each(h, &out_key, &out_value)) { 17472 8 17480
478 17472 ▶ EXTEND(SP, 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 2); 0 17472 17472
479 17472 ▶ mXPUSHi(out_key);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi(out_key); 0 17472 17472
480 17472 ▶ mXPUSHi(out_value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi(out_value); 0 17472 17472
481 17472 XSRETURN(2);
482 }
483 8 shm_ii_flush_deferred(h);
484 8 XSRETURN_EMPTY;
485  
486 void
487 iter_reset(SV* self_sv)
488 CODE:
489 3 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 3 3
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 3 3
490 3 shm_ii_iter_reset(h);
491 3 shm_ii_flush_deferred(h);
492  
493 void
494 clear(SV* self_sv)
495 CODE:
496 6 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 6 6
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 6 6
497 6 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 4 2 6
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 3 4
498 3 shm_ii_clear(h);
499  
500 SV*
501 to_hash(SV* self_sv)
502 CODE:
503 8 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 8 8
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 8 8
504 8 SV* raw = sv_2mortal(newSV(1));
505 8 SSize_t n = 0, nraw = 0;
506 8 ▶ uint32_t ns = h->shard_handles ? h->num_shards : 1;
Branch: 1 branch
BranchTrueFalseTotal
uint32_t ns = h->shard_handles ? h->num_shards : 1; 1 7 8
507 8 ENTER;
508 19 ▶ for (uint32_t si = 0; si < ns; si++) {
Branch: 1 branch
BranchTrueFalseTotal
for (uint32_t si = 0; si < ns; si++) { 11 8 19
509 11 ▶ ShmHandle *sh = h->shard_handles ? h->shard_handles[si] : h;
Branch: 1 branch
BranchTrueFalseTotal
ShmHandle *sh = h->shard_handles ? h->shard_handles[si] : h; 4 7 11
510 11 ShmHeader *hdr = sh->hdr;
511 11 ShmNodeII *nodes = (ShmNodeII *)sh->nodes;
512 11 RDLOCK_GUARD(sh);
513 11 ▶ uint32_t now = sh->expires_at ? shm_now() : 0, left = hdr->size;
Branch: 1 branch
BranchTrueFalseTotal
uint32_t now = sh->expires_at ? shm_now() : 0, left = hdr->size; 5 6 11
514 11 ▶ IV *r = (IV *)SvGROW(raw, (nraw + 2 * (STRLEN)left) * sizeof(IV) + 1);
Branch: 2 branches
BranchTrueFalseTotal
IV *r = (IV *)SvGROW(raw, (nraw + 2 * (STRLEN)left) * sizeof(IV) + 1); 11 0 11
IV *r = (IV *)SvGROW(raw, (nraw + 2 * (STRLEN)left) * sizeof(IV) + 1); 11 0 11
515 2392 ▶ for (uint32_t i = 0; i < hdr->table_cap && left; i++) {
Branch: 2 branches
BranchTrueFalseTotal
for (uint32_t i = 0; i < hdr->table_cap && left; i++) { 2383 9 2392
for (uint32_t i = 0; i < hdr->table_cap && left; i++) { 2381 2 2383
516 2381 ▶ if (SHM_IS_LIVE(sh->states[i]) && !SHM_IS_EXPIRED(sh, i, now)) {
Branch: 4 branches
BranchTrueFalseTotal
if (SHM_IS_LIVE(sh->states[i]) && !SHM_IS_EXPIRED(sh, i, now)) { 1194 1187 2381
if (SHM_IS_LIVE(sh->states[i]) && !SHM_IS_EXPIRED(sh, i, now)) { 90 1104 1194
if (SHM_IS_LIVE(sh->states[i]) && !SHM_IS_EXPIRED(sh, i, now)) { 90 0 90
if (SHM_IS_LIVE(sh->states[i]) && !SHM_IS_EXPIRED(sh, i, now)) { 88 2 90
517 1192 r[nraw++] = (IV)nodes[i].key;
518 1192 r[nraw++] = (IV)__atomic_load_n(&nodes[i].value, __ATOMIC_RELAXED);
519 1192 n++; left--;
520 }
521 }
522 }
523 8 LEAVE;
524  
525 8 RETVAL = shm_copies_to_hashref(aTHX_ raw, NULL, NULL, n);
526 OUTPUT:
527 RETVAL
528  
529 SV*
530 get_or_set(SV* self_sv, int64_t key, int64_t default_value)
531 CODE:
532 42 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 42 42
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 42 42
533 42 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 40 2 42
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 39 40
534 int64_t out;
535 39 int rc = shm_ii_get_or_set(h, key, default_value, &out);
536 39 ▶ if (!rc) XSRETURN_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if (!rc) XSRETURN_UNDEF; 2 37 39
537 37 RETVAL = newSViv(out);
538 OUTPUT:
539 RETVAL
540  
541 bool
542 put_ttl(SV* self_sv, int64_t key, int64_t value, SV* ttl_sec_sv)
543 CODE:
544 18309 uint32_t ttl_sec = shm_u32_arg(aTHX_ ttl_sec_sv, "ttl", "Data::HashMap::Shared::II", 0);
545 18305 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 18305 18305
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 18305 18305
546 18305 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 18304 1 18305
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 18303 18304
547 18303 ▶ REQUIRE_TTL(h);
Branch: 2 branches
BranchTrueFalseTotal
REQUIRE_TTL(h); 83 18220 18303
REQUIRE_TTL(h); 1 18302 18303
548 18302 ▶ RETVAL = shm_ii_put_ttl(h, key, value, (uint32_t)ttl_sec);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = shm_ii_put_ttl(h, key, value, (uint32_t)ttl_sec); 18302 0 18302
549 OUTPUT:
550 RETVAL
551  
552 UV
553 max_size(SV* self_sv)
554 CODE:
555 4 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 4 4
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 4 4
556 4 RETVAL = (UV)shm_ii_max_size(h);
557 OUTPUT:
558 RETVAL
559  
560 UV
561 ttl(SV* self_sv)
562 CODE:
563 0 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 0 0
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 0 0
564 0 ▶ RETVAL = (UV)shm_ii_ttl(h);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)shm_ii_ttl(h); 0 0 0
565 OUTPUT:
566 RETVAL
567  
568 SV*
569 take(SV* self_sv, int64_t key)
570 CODE:
571 2 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 2 2
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 2 2
572 2 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 1 2
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 0 1
573 int64_t out_value;
574 0 ▶ if (!shm_ii_take(h, key, &out_value)) XSRETURN_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if (!shm_ii_take(h, key, &out_value)) XSRETURN_UNDEF; 0 0 0
575 0 RETVAL = newSViv(out_value);
576 OUTPUT:
577 RETVAL
578  
579 void
580 pop(SV* self_sv)
581 PPCODE:
582 124 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 124 124
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 124 124
583 124 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 123 1 124
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 122 123
584 int64_t out_key;
585 int64_t out_val;
586 122 ▶ if (!shm_ii_pop(h, &out_key, &out_val)) XSRETURN_EMPTY;
Branch: 1 branch
BranchTrueFalseTotal
if (!shm_ii_pop(h, &out_key, &out_val)) XSRETURN_EMPTY; 5 117 122
587 117 ▶ EXTEND(SP, 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 2); 0 117 117
588 117 mPUSHi(out_key);
589 117 mPUSHi(out_val);
590  
591 void
592 shift(SV* self_sv)
593 PPCODE:
594 428 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 428 428
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 428 428
595 428 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 427 1 428
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 426 427
596 int64_t out_key;
597 int64_t out_val;
598 426 ▶ if (!shm_ii_shift(h, &out_key, &out_val)) XSRETURN_EMPTY;
Branch: 1 branch
BranchTrueFalseTotal
if (!shm_ii_shift(h, &out_key, &out_val)) XSRETURN_EMPTY; 5 421 426
599 421 ▶ EXTEND(SP, 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 2); 0 421 421
600 421 mPUSHi(out_key);
601 421 mPUSHi(out_val);
602  
603 void
604 drain(SV* self_sv, SV* limit_sv)
605 PPCODE:
606 16 UV limit = shm_count_arg(aTHX_ limit_sv, "drain limit", "Data::HashMap::Shared::II");
607 16 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 16 16
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 16 16
608 16 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 15 1 16
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 14 15
609 /* Only as many as the map can yield: limit sizes the allocation. */
610 {
611 14 UV avail = (UV)shm_ii_size(h);
612 14 ▶ if (limit > avail) limit = avail;
Branch: 1 branch
BranchTrueFalseTotal
if (limit > avail) limit = avail; 5 9 14
613 14 ▶ if (limit > UINT32_MAX) limit = UINT32_MAX;
Branch: 1 branch
BranchTrueFalseTotal
if (limit > UINT32_MAX) limit = UINT32_MAX; 0 14 14
614 }
615 14 ▶ if (limit == 0) XSRETURN_EMPTY;
Branch: 1 branch
BranchTrueFalseTotal
if (limit == 0) XSRETURN_EMPTY; 0 14 14
616 shm_ii_drain_entry *entries;
617 14 ▶ Newxz(entries, limit, shm_ii_drain_entry);
Branch: 1 branch
BranchTrueFalseTotal
Newxz(entries, limit, shm_ii_drain_entry); 0 14 14
618  
619 14 SAVEFREEPV(entries);
620 14 char *buf = NULL; uint32_t buf_cap = 0;
621 14 uint32_t n = shm_ii_drain(h, (uint32_t)limit, entries, &buf, &buf_cap);
622 14 ▶ if (buf) SAVEDESTRUCTOR_X(shm_free_cleanup, buf);
Branch: 1 branch
BranchTrueFalseTotal
if (buf) SAVEDESTRUCTOR_X(shm_free_cleanup, buf); 0 14 14
623  
624 14 ▶ EXTEND(SP, (SSize_t)n * 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, (SSize_t)n * 2); 1 13 14
625 20343 ▶ for (uint32_t i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (uint32_t i = 0; i < n; i++) { 20329 14 20343
626 20329 mPUSHi(entries[i].key);
627 20329 mPUSHi(entries[i].value);
628 }
629  
630  
631 UV
632 flush_expired(SV* self_sv)
633 CODE:
634 7 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 7 7
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 7 7
635 7 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 6 1 7
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 5 6
636 5 ▶ RETVAL = (UV)shm_ii_flush_expired(h);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)shm_ii_flush_expired(h); 0 5 5
637 OUTPUT:
638 RETVAL
639  
640 void
641 flush_expired_partial(SV* self_sv, SV* limit_sv)
642 PPCODE:
643 1252 uint32_t limit = shm_u32_arg(aTHX_ limit_sv, "limit", "Data::HashMap::Shared::II", 0);
644 1249 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 1249 1249
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 1249 1249
645 1249 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1248 1 1249
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 1247 1248
646 1247 int done = 0;
647 1247 uint32_t flushed = shm_ii_flush_expired_partial(h, (uint32_t)limit, &done);
648 1247 ▶ EXTEND(SP, 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 2); 0 1247 1247
649 1247 mPUSHu(flushed);
650 1247 mPUSHi(done);
651  
652 UV
653 mmap_size(SV* self_sv)
654 CODE:
655 3 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 3 3
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 3 3
656 3 RETVAL = (UV)shm_ii_mmap_size(h);
657 OUTPUT:
658 RETVAL
659  
660 bool
661 touch(SV* self_sv, int64_t key)
662 CODE:
663 27 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 27 27
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 27 27
664 27 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 26 1 27
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 25 26
665 25 ▶ RETVAL = shm_ii_touch(h, key);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = shm_ii_touch(h, key); 22 3 25
666 OUTPUT:
667 RETVAL
668  
669 bool
670 reserve(SV* self_sv, SV* target_sv)
671 CODE:
672 25 uint32_t target = shm_u32_arg(aTHX_ target_sv, "target", "Data::HashMap::Shared::II", 0);
673 21 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 21 21
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 21 21
674 21 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 20 1 21
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 19 20
675 19 ▶ RETVAL = shm_ii_reserve(h, (uint32_t)target);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = shm_ii_reserve(h, (uint32_t)target); 14 5 19
676 OUTPUT:
677 RETVAL
678  
679 UV
680 stat_evictions(SV* self_sv)
681 CODE:
682 8 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 8 8
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 8 8
683 8 RETVAL = (UV)shm_ii_stat_evictions(h);
684 OUTPUT:
685 RETVAL
686  
687 UV
688 stat_expired(SV* self_sv)
689 CODE:
690 4 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 4 4
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 4 4
691 4 RETVAL = (UV)shm_ii_stat_expired(h);
692 OUTPUT:
693 RETVAL
694  
695 UV
696 stat_recoveries(SV* self_sv)
697 CODE:
698 1 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 1 1
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 1 1
699 1 RETVAL = (UV)shm_ii_stat_recoveries(h);
700 OUTPUT:
701 RETVAL
702  
703 UV
704 compact(SV* self_sv)
705 CODE:
706 3 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 3 3
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 3 3
707 3 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 2 1 3
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 1 2
708 1 RETVAL = (UV)shm_ii_compact(h);
709 OUTPUT:
710 RETVAL
711  
712 UV
713 arena_used(SV* self_sv)
714 CODE:
715 0 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 0 0
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 0 0
716 0 RETVAL = (UV)shm_ii_arena_used(h);
717 OUTPUT:
718 RETVAL
719  
720 UV
721 arena_cap(SV* self_sv)
722 CODE:
723 1 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 1 1
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 1 1
724 1 RETVAL = (UV)shm_ii_arena_cap(h);
725 OUTPUT:
726 RETVAL
727  
728 bool
729 add(SV* self_sv, int64_t key, int64_t value)
730 CODE:
731 3 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 3 3
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 3 3
732 3 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 2 3
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 0 1
733 0 ▶ RETVAL = shm_ii_add(h, key, value);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = shm_ii_add(h, key, value); 0 0 0
734 OUTPUT:
735 RETVAL
736  
737 bool
738 add_ttl(SV* self_sv, int64_t key, int64_t value, SV* ttl_sec_sv)
739 CODE:
740 13 uint32_t ttl_sec = shm_u32_arg(aTHX_ ttl_sec_sv, "ttl", "Data::HashMap::Shared::II", 0);
741 10 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 10 10
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 10 10
742 10 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 9 1 10
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 8 9
743 8 ▶ REQUIRE_TTL(h);
Branch: 2 branches
BranchTrueFalseTotal
REQUIRE_TTL(h); 0 8 8
REQUIRE_TTL(h); 2 6 8
744 6 ▶ RETVAL = shm_ii_add_ttl(h, key, value, (uint32_t)ttl_sec);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = shm_ii_add_ttl(h, key, value, (uint32_t)ttl_sec); 5 1 6
745 OUTPUT:
746 RETVAL
747  
748 bool
749 update(SV* self_sv, int64_t key, int64_t value)
750 CODE:
751 2 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 2 2
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 2 2
752 2 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 1 2
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 0 1
753 0 ▶ RETVAL = shm_ii_update(h, key, value);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = shm_ii_update(h, key, value); 0 0 0
754 OUTPUT:
755 RETVAL
756  
757 bool
758 update_ttl(SV* self_sv, int64_t key, int64_t value, SV* ttl_sec_sv)
759 CODE:
760 11 uint32_t ttl_sec = shm_u32_arg(aTHX_ ttl_sec_sv, "ttl", "Data::HashMap::Shared::II", 0);
761 8 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 8 8
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 8 8
762 8 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 7 1 8
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 6 7
763 6 ▶ REQUIRE_TTL(h);
Branch: 2 branches
BranchTrueFalseTotal
REQUIRE_TTL(h); 0 6 6
REQUIRE_TTL(h); 2 4 6
764 4 ▶ RETVAL = shm_ii_update_ttl(h, key, value, (uint32_t)ttl_sec);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = shm_ii_update_ttl(h, key, value, (uint32_t)ttl_sec); 3 1 4
765 OUTPUT:
766 RETVAL
767  
768 SV*
769 swap(SV* self_sv, int64_t key, int64_t value)
770 CODE:
771 4 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 4 4
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 4 4
772 4 ▶ if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)");
Branch: 2 branches
BranchTrueFalseTotal
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 3 1 4
if (h->readonly || shm_is_sealed(h)) croak("Data::HashMap::Shared::II: map is frozen (read-only)"); 1 2 3
773 int64_t out_value;
774 2 int rc = shm_ii_swap(h, key, value, &out_value);
775 2 ▶ if (rc != 1) XSRETURN_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if (rc != 1) XSRETURN_UNDEF; 0 2 2
776 2 RETVAL = newSViv(out_value);
777 OUTPUT:
778 RETVAL
779  
780 SV*
781 path(SV* self_sv)
782 CODE:
783 4 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 4 4
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 4 4
784 4 ▶ RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef; 2 2 4
785 OUTPUT:
786 RETVAL
787  
788 bool
789 unlink(SV* self_or_class, ...)
790 CODE:
791 15 ▶ if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::HashMap::Shared::II")) {
Branch: 2 branches
BranchTrueFalseTotal
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::HashMap::Shared::II")) { 7 8 15
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::HashMap::Shared::II")) { 7 0 7
792 7 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_or_class);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_or_class); 0 7 7
EXTRACT_MAP("Data::HashMap::Shared::II", self_or_class); 0 7 7
793 7 ▶ if (h->path) {
Branch: 1 branch
BranchTrueFalseTotal
if (h->path) { 7 0 7
794 7 ▶ SHM_TAINT_CHECK("Data::HashMap::Shared::II->unlink");
Branch: 1 branch
BranchTrueFalseTotal
SHM_TAINT_CHECK("Data::HashMap::Shared::II->unlink"); 4 3 7
795 5 ▶ REEXTRACT_MAP("Data::HashMap::Shared::II", self_or_class);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_MAP("Data::HashMap::Shared::II", self_or_class); 1 4 5
REEXTRACT_MAP("Data::HashMap::Shared::II", self_or_class); 0 4 4
796 }
797 4 RETVAL = shm_unlink_sharded(h);
798 } else {
799 8 ▶ if (items < 2) croak("Usage: Data::HashMap::Shared::II->unlink($path)");
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) croak("Usage: Data::HashMap::Shared::II->unlink($path)"); 1 7 8
800 7 ▶ SvGETMAGIC(ST(1));
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(ST(1)); 2 5 7
SvGETMAGIC(ST(1)); 0 2 2
801 7 RETVAL = shm_unlink_path(shm_write_path_arg(aTHX_ ST(1), "path", "Data::HashMap::Shared::II", "Data::HashMap::Shared::II->unlink"));
802 }
803 OUTPUT:
804 RETVAL
805  
806 SV*
807 ttl_remaining(SV* self_sv, int64_t key)
808 CODE:
809 67 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 67 67
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 67 67
810 67 int64_t remaining = shm_ii_ttl_remaining(h, key);
811 67 ▶ if (remaining < 0) XSRETURN_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if (remaining < 0) XSRETURN_UNDEF; 33 34 67
812 34 RETVAL = newSViv(remaining);
813 OUTPUT:
814 RETVAL
815  
816 UV
817 capacity(SV* self_sv)
818 CODE:
819 103 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 103 103
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 103 103
820 103 RETVAL = (UV)shm_ii_capacity(h);
821 OUTPUT:
822 RETVAL
823  
824 UV
825 tombstones(SV* self_sv)
826 CODE:
827 12 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 12 12
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 12 12
828 12 RETVAL = (UV)shm_ii_tombstones(h);
829 OUTPUT:
830 RETVAL
831  
832 SV*
833 cursor(SV* self_sv)
834 CODE:
835 19 ▶ EXTRACT_MAP("Data::HashMap::Shared::II", self_sv);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 19 19
EXTRACT_MAP("Data::HashMap::Shared::II", self_sv); 0 19 19
836 19 ShmCursor* c = shm_cursor_create(h);
837 19 ▶ if (!c) croak("%s: failed to allocate a cursor", shm_class);
Branch: 1 branch
BranchTrueFalseTotal
if (!c) croak("%s: failed to allocate a cursor", shm_class); 0 19 19
838 19 c->owner = SvREFCNT_inc(SvRV(self_sv));
839 19 RETVAL = sv_setref_pv(newSV(0), "Data::HashMap::Shared::II::Cursor", (void*)c);
840 OUTPUT:
841 RETVAL
842  
843 MODULE = Data::HashMap::Shared PACKAGE = Data::HashMap::Shared::II::Cursor
844 PROTOTYPES: DISABLE
845  
846 void
847 DESTROY(SV* self_sv)
848 CODE:
849 19 ▶ if (!sv_isobject(self_sv) || !sv_derived_from(self_sv, "Data::HashMap::Shared::II::Cursor")) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!sv_isobject(self_sv) || !sv_derived_from(self_sv, "Data::HashMap::Shared::II::Cursor")) return; 19 0 19
if (!sv_isobject(self_sv) || !sv_derived_from(self_sv, "Data::HashMap::Shared::II::Cursor")) return; 0 19 19
850 19 ShmCursor* c = INT2PTR(ShmCursor*, SvIV(SvRV(self_sv)));
851 19 ▶ if (!c) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!c) return; 0 19 19
852 19 ▶ CURSOR_DETACH_IF_MAP_GONE(c, owner, h);
Branch: 3 branches
BranchTrueFalseTotal
CURSOR_DETACH_IF_MAP_GONE(c, owner, h); 19 0 19
CURSOR_DETACH_IF_MAP_GONE(c, owner, h); 19 0 19
CURSOR_DETACH_IF_MAP_GONE(c, owner, h); 12 7 19
853 19 shm_cursor_destroy(c);
854 19 ▶ if (h) shm_ii_flush_deferred(h);
Branch: 1 branch
BranchTrueFalseTotal
if (h) shm_ii_flush_deferred(h); 7 12 19
855 19 ▶ if (owner) SvREFCNT_dec(owner);
Branch: 1 branch
BranchTrueFalseTotal
if (owner) SvREFCNT_dec(owner); 19 0 19
856 19 sv_setiv(SvRV(self_sv), 0);
857  
858 void
859 next(SV* self_sv)
860 PPCODE:
861 2495 ▶ EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv);
Branch: 4 branches
BranchTrueFalseTotal
EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv); 2 2493 2495
EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv); 0 2493 2493
EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv); 2493 0 2493
EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv); 0 2493 2493
862 int64_t out_key, out_value;
863 2493 ▶ if (shm_ii_cursor_next(c, &out_key, &out_value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (shm_ii_cursor_next(c, &out_key, &out_value)) { 2478 15 2493
864 2478 ▶ EXTEND(SP, 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 2); 0 2478 2478
865 2478 ▶ mXPUSHi(out_key);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi(out_key); 0 2478 2478
866 2478 ▶ mXPUSHi(out_value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi(out_value); 0 2478 2478
867 2478 XSRETURN(2);
868 }
869 15 XSRETURN_EMPTY;
870  
871 void
872 reset(SV* self_sv)
873 CODE:
874 2 ▶ EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv);
Branch: 4 branches
BranchTrueFalseTotal
EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv); 0 2 2
EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv); 0 2 2
EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv); 2 0 2
EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv); 0 2 2
875 2 shm_ii_cursor_reset(c);
876  
877 bool
878 seek(SV* self_sv, int64_t key)
879 CODE:
880 49 ▶ EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv);
Branch: 4 branches
BranchTrueFalseTotal
EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv); 0 49 49
EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv); 0 49 49
EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv); 49 0 49
EXTRACT_CURSOR("Data::HashMap::Shared::II::Cursor", self_sv); 0 49 49
881 49 ▶ RETVAL = shm_ii_cursor_seek(c, key);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = shm_ii_cursor_seek(c, key); 4 45 49
882 OUTPUT:
883 RETVAL
884  
« xs/ss.xs ↑ Summary Shared.xs »