リビジョン | 9b0ec5e256775e4e84fce41aa20baa5c73aeb6a9 (tree) |
---|---|
日時 | 2018-12-05 03:59:17 |
作者 | Agustina Arzille <avarzille@rise...> |
コミッター | Agustina Arzille |
Add the lwlock_guard's
@@ -1355,7 +1355,6 @@ | ||
1355 | 1355 | interp->raise2 ("arg-error", "%use: import list must " |
1356 | 1356 | "consist of strings or symbols"); |
1357 | 1357 | |
1358 | - | |
1359 | 1358 | valref sv (interp, find_sym (interp, p->as_obj (), snam)); |
1360 | 1359 | if (*sv & EXTRA_BIT) |
1361 | 1360 | interp->raise2 ("load-error", io_sprintf (interp, |
@@ -274,35 +274,31 @@ | ||
274 | 274 | tp->vector = newvp->as_obj (); |
275 | 275 | } |
276 | 276 | |
277 | -struct lwlock_guard | |
277 | +struct table_guard : public lwlock_guard | |
278 | 278 | { |
279 | - atomic_t *lockp; | |
280 | 279 | array *oldp; |
281 | 280 | |
282 | - lwlock_guard (atomic_t *ptr) : lockp (ptr), oldp (nullptr) | |
283 | - { | |
284 | - lwlock_grab (this->lockp); | |
285 | - } | |
281 | + table_guard (atomic_t *ptr) : lwlock_guard (ptr), oldp (nullptr) {} | |
286 | 282 | |
287 | 283 | void set_vec (array *ap) |
288 | 284 | { |
289 | 285 | this->oldp = ap; |
290 | 286 | } |
291 | 287 | |
292 | - ~lwlock_guard () | |
288 | + ~table_guard () | |
293 | 289 | { |
294 | - if (this->oldp != nullptr) | |
295 | - for (int i = tabvec_idx (0); i < this->oldp->len; i += 2) | |
296 | - atomic_and ((atomic_t *)&oldp->data[i + 1], ~EXTRA_BIT); | |
290 | + if (!this->oldp) | |
291 | + return; | |
297 | 292 | |
298 | - lwlock_drop (this->lockp); | |
293 | + for (int i = tabvec_idx (0); i < this->oldp->len; i += 2) | |
294 | + atomic_and ((atomic_t *)&oldp->data[i + 1], ~EXTRA_BIT); | |
299 | 295 | } |
300 | 296 | }; |
301 | 297 | |
302 | 298 | static void |
303 | 299 | table_migrate_mt (interpreter *interp, table *tp) |
304 | 300 | { |
305 | - lwlock_guard g (&tp->lock); | |
301 | + table_guard g (&tp->lock); | |
306 | 302 | |
307 | 303 | if (tp->grow_limit <= 0) |
308 | 304 | { |
@@ -579,7 +575,7 @@ | ||
579 | 575 | array *vecp = as_array (tp->vector); |
580 | 576 | array *np = make_tabvec (interp, 0); |
581 | 577 | |
582 | - lwlock_guard g (&tp->lock); | |
578 | + table_guard g (&tp->lock); | |
583 | 579 | |
584 | 580 | for (int ix = TABVEC_OVERHEAD; ix < vecp->len; ix += 2) |
585 | 581 | { |
@@ -166,6 +166,21 @@ | ||
166 | 166 | } |
167 | 167 | }; |
168 | 168 | |
169 | +struct lwlock_guard | |
170 | +{ | |
171 | + atomic_t *lockp; | |
172 | + | |
173 | + lwlock_guard (atomic_t *lp) : lockp (lp) | |
174 | + { | |
175 | + lwlock_grab (this->lockp); | |
176 | + } | |
177 | + | |
178 | + ~lwlock_guard () | |
179 | + { | |
180 | + lwlock_drop (this->lockp); | |
181 | + } | |
182 | +}; | |
183 | + | |
169 | 184 | struct condvar : public finobj |
170 | 185 | { |
171 | 186 | xcondvar_t cond; |