Re: atomic increment

2008-08-27 Thread Fredrik Lundh
Frank Millman wrote: Just out of interest, would the following, without a lock, be safe? old, atomic_int = atomic_int, atomic_int+1 nope. there's some information here (make sure you read the comments): http://effbot.org/pyfaq/what-kinds-of-global-value-mutation-are-thread-safe.htm and som

Re: atomic increment

2008-08-26 Thread Paul Rubin
Frank Millman <[EMAIL PROTECTED]> writes: > Just out of interest, would the following, without a lock, be safe? > old, atomic_int = atomic_int, atomic_int+1 No I don't think so. But I'm told that in CPython, you can say counter = iter(xrange(1000)) # some number that exceeds wh

Re: atomic increment

2008-08-26 Thread Frank Millman
On Aug 26, 5:56 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Alexandru  Mosoi wrote: > > how can i do an atomic read+increment? something like > > > with lock: > >    old = atomic_int > >    atomic_int += 1 > > > but in one operation > > As above - the lock (under the assumption that it is a

Re: atomic increment

2008-08-26 Thread Diez B. Roggisch
Alexandru Mosoi wrote: > how can i do an atomic read+increment? something like > > with lock: >old = atomic_int >atomic_int += 1 > > but in one operation As above - the lock (under the assumption that it is actually a threading.Lock) will ensure that. Diez -- http://mail.python.org/ma

atomic increment

2008-08-26 Thread Alexandru Mosoi
how can i do an atomic read+increment? something like with lock: old = atomic_int atomic_int += 1 but in one operation -- http://mail.python.org/mailman/listinfo/python-list