Commit 63dce352 authored by Xavier Thompson's avatar Xavier Thompson

Stop using RAII for cypclass automatic lock acquisition

parent 961865dc
......@@ -14197,20 +14197,19 @@ class CoerceToLockedNode(CoercionNode):
return self.arg.may_be_none()
def generate_result_code(self, code):
# Create a scope to use scope bound resource management (RAII).
code.putln("{")
# Since each lock guard has its onw scope,
# a prefix is enough to prevent name collisions.
guard_code = "%sguard" % Naming.cypclass_lock_guard_prefix
# Acquire the lock.
if self.rlock_only:
code.putln("Cy_rlock_guard %s(%s);" % (guard_code, self.result()))
code.putln("Cy_RLOCK(%s);" % self.result())
else:
code.putln("Cy_wlock_guard %s(%s);" % (guard_code, self.result()))
code.putln("Cy_WLOCK(%s);" % self.result())
def generate_disposal_code(self, code):
# Close the scope to release the lock.
code.putln("}")
# Release the lock.
if self.rlock_only:
code.putln("Cy_UNRLOCK(%s);" % self.result())
else:
code.putln("Cy_UNWLOCK(%s);" % self.result())
# The subexpressions of self.arg are disposed-of and freed
# as soon as self.arg is evaluated because it is a temporary.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment