Message139160
| Author |
neologix |
| Recipients |
greg.ath, neologix, pitrou, vstinner |
| Date |
2011年06月26日.10:14:00 |
| SpamBayes Score |
0.00010895956 |
| Marked as misclassified |
No |
| Message-id |
<BANLkTi=2eazNTXLs3GayOO-ijXbm_D+N9A@mail.gmail.com> |
| In-reply-to |
<1309048593.28727.8.camel@marge> |
| Content |
> 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()) |
|