Message139160
> 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()) |
|
Date |
User |
Action |
Args |
2011-06-26 10:14:01 | neologix | set | recipients:
+ neologix, pitrou, vstinner, greg.ath |
2011-06-26 10:14:00 | neologix | link | issue12352 messages |
2011-06-26 10:14:00 | neologix | create | |
|