[Zope-dev] ThreadSafeCounter 0.0.1 released
Chris Withers
chrisw@nipltd.com
Sun, 11 Feb 2001 15:24:27 +0000
"Morten W. Petersen" wrote:
>
> There's a new product available, which enables unique ids in a given context,
> take a look at <url:http://www.zope.org/Members/morphex/ThreadSafeCounter>.
So would a counter such as:
class PersistentCounter(Persistent):
# create the counter
def __init__(self, value=0):
self._value = value
# get the value of the counter without incrementing
def getValue(self):
return self._value
# increment the counter when called, and return the new value
def __call__(self, number=1):
self._value = self._value + number
return self._value
...not be thread safe?
If not, can anyone explain how it could be made thread safe?
cheers,
Chris