... sometimes. The reason it seems to work is that python integers are immutable and the safe count is always zero :) You could assign back to SafeCount the result of the increment, but the assignment isn't necessarily safe. I guess these kinds of things either need to be written in C#, or use a Monitor or Lock as always in Python.
-Dan On Fri, Nov 14, 2008 at 11:18 AM, Dan Eloff <[EMAIL PROTECTED]> wrote: > I've often wondered if the CLR Interlocked methods work with > IronPython. It seems that Interlocked.Increment works fine with module > globals (see attached script.) Whether it works fine in general I > don't know. Does anybody know anything about this? > > -Dan > >>ipy interlockedinc.py > UnsafeCount: -32081 > SafeCount: 0 > >>ipy interlockedinc.py > UnsafeCount: -27749 > SafeCount: 0 > >>ipy interlockedinc.py > UnsafeCount: -37339 > SafeCount: 0 > >>ipy interlockedinc.py > UnsafeCount: -39461 > SafeCount: 0 > >>ipy interlockedinc.py > UnsafeCount: 23175 > SafeCount: 0 > _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
