On Tuesday, 29 October 2013 at 21:59:38 UTC, Joseph Rushton
Wakeling wrote:
On 29/10/13 15:58, Dmitry Olshansky wrote:
Can't it use ref-counted COW? Then since there is only 1
reference to the
original block it may mutate it in-place else it creates new
chunk with refs=1
and decrements the original count. Maybe I'm missing something
but it shouldn't
be that hard.
Yes, that's pretty much what I was thinking of. The question
is how to implement it in terms of std.allocator -- or is that
the wrong base to build ref=counted memory upon?
Implement a pool of bigints as an allocator: when refcount
reaches zero, return the bigint buffer to the pool - a simple
bump the pointer algorithm, when you need a new buffer, request
it from the pool. A pool is a stack with fixed capacity, and
buffers go in and out.