Charles-François Natali <[email protected]> added the comment:
> You are probably right. Can't we use a lock-less list? list.append is
> atomic thanks to the GIL, isn't it? But I don't know how to implement
> the lock-less list consumer. It would be nice to have a function to
> remove and return the content of the list, an atomic "content=mylist[:];
> del mylist[:]" function.
>
While not just something like:
While True:
try:
block = list.pop()
except IndexError:
break
_free(block)
Lock-less lists are not strictly atomic (only on cPython), but I doubt
that gc.disable() is available and works on every Python interpreter
anyway...
So the idea would be:
- in free(), perform a trylock
- if trylock fails, append the block to a list of pending blocks to free
- if trylock succeeds, free the pending blocks and proceed as usual
(do the same thing in malloc())
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue12352>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com