Roman Suzi <rnd@onego.ru>: > I have not thought about locking objects, but locking places of a > program from multiple entry. If we're to have implicit lock objects, this is perhaps the right way to think about it. But the locking needs to apply to more than just one code block. Consider def increment(self): synchronize: self.count += 1 def decrement(self): synchronize: self.count -= 1 If the two statements are synchronized independently, this will not work. I think the right level to synchronize at is a whole class: synchronized class Counter: def __init__(self): self.counter = 0 def increment(self): self.count += 1 def decrement(self): self.count -= 1 the semantics being that each instance of Counter gets its own lock object, and the lock is acquired before any method in it is entered and released when it is exited. Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4