Chris Withers wrote:

> "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?

That's not the issue. Morten's product stores the counter's
value in a file on the filesystem, and so it doesn't cause the
Data.fs to grow.

The trade-off is that it doesn't participate in history or undo.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net


_______________________________________________
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to