コミットメタ情報

リビジョン9b0ec5e256775e4e84fce41aa20baa5c73aeb6a9 (tree)
日時2018-12-05 03:59:17
作者Agustina Arzille <avarzille@rise...>
コミッターAgustina Arzille

ログメッセージ

Add the lwlock_guard's

変更サマリ

差分

diff -r ef339585a431 -r 9b0ec5e25677 builtins.cpp
--- a/builtins.cpp Tue Dec 04 15:46:46 2018 -0300
+++ b/builtins.cpp Tue Dec 04 15:59:17 2018 -0300
@@ -1355,7 +1355,6 @@
13551355 interp->raise2 ("arg-error", "%use: import list must "
13561356 "consist of strings or symbols");
13571357
1358-
13591358 valref sv (interp, find_sym (interp, p->as_obj (), snam));
13601359 if (*sv & EXTRA_BIT)
13611360 interp->raise2 ("load-error", io_sprintf (interp,
diff -r ef339585a431 -r 9b0ec5e25677 table.cpp
--- a/table.cpp Tue Dec 04 15:46:46 2018 -0300
+++ b/table.cpp Tue Dec 04 15:59:17 2018 -0300
@@ -274,35 +274,31 @@
274274 tp->vector = newvp->as_obj ();
275275 }
276276
277-struct lwlock_guard
277+struct table_guard : public lwlock_guard
278278 {
279- atomic_t *lockp;
280279 array *oldp;
281280
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) {}
286282
287283 void set_vec (array *ap)
288284 {
289285 this->oldp = ap;
290286 }
291287
292- ~lwlock_guard ()
288+ ~table_guard ()
293289 {
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;
297292
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);
299295 }
300296 };
301297
302298 static void
303299 table_migrate_mt (interpreter *interp, table *tp)
304300 {
305- lwlock_guard g (&tp->lock);
301+ table_guard g (&tp->lock);
306302
307303 if (tp->grow_limit <= 0)
308304 {
@@ -579,7 +575,7 @@
579575 array *vecp = as_array (tp->vector);
580576 array *np = make_tabvec (interp, 0);
581577
582- lwlock_guard g (&tp->lock);
578+ table_guard g (&tp->lock);
583579
584580 for (int ix = TABVEC_OVERHEAD; ix < vecp->len; ix += 2)
585581 {
diff -r ef339585a431 -r 9b0ec5e25677 thread.h
--- a/thread.h Tue Dec 04 15:46:46 2018 -0300
+++ b/thread.h Tue Dec 04 15:59:17 2018 -0300
@@ -166,6 +166,21 @@
166166 }
167167 };
168168
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+
169184 struct condvar : public finobj
170185 {
171186 xcondvar_t cond;
旧リポジトリブラウザで表示