From: Mark H Weaver <mhw@netris.org> Date: Sun, 1 Mar 2015 14:07:30 +0000 (+0100) Subject: Issue 4304: Smob code changes mostly relevant for multithreading X-Git-Tag: release/2.19.17-1~14^2~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=2f7cc8c9e89474feb89d1c435d8dc9b43235cc1c;p=lilypond.git Issue 4304: Smob code changes mostly relevant for multithreading These changes have been suggested by Mark H Weaver in <URL:http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19883#41> Signed-off-by: David Kastrup <dak@gnu.org> --- diff --git a/lily/include/smobs.hh b/lily/include/smobs.hh index a816b67ca3..3ee2ef80ab 100644 --- a/lily/include/smobs.hh +++ b/lily/include/smobs.hh @@ -266,21 +266,22 @@ public: } SCM unprotected_smobify_self () { - self_scm_ = Smob_base<Super>::register_ptr (static_cast<Super *> (this)); - return self_scm_; + SCM s = Smob_base<Super>::register_ptr (static_cast<Super *> (this)); + self_scm_ = s; + return s; } void protect () { protect_smob (self_scm_, &protection_cons_); } + void smobify_self () { + protect_smob (unprotected_smobify_self (), &protection_cons_); + } SCM unprotect () { - unprotect_smob (self_scm_, &protection_cons_); - return self_scm_; - } - void smobify_self () { - self_scm_ = unprotected_smobify_self (); - protect (); + SCM s = self_scm_; + unprotect_smob (s, &protection_cons_); + return s; } SCM self_scm () const { return self_scm_; } };