Memory pool allocator in ATS

Hello all,

I think ATS needs more flexible means of working with mutable dynamic data
without GC. Especially if sharing is desired, and the sharing patterns are
very intricate.

I wanted to present this module:

See, in particular, the usage: functions do_stuff and do_other_stuff. Seems
easy enough to use (I will probably further simplify indices of the
abstract types).

It shows a very simple array-based memory pool allocator (rbuf) in ATS.
Pointers given out by the allocator are non-linear, but will require a
linear permission to access (so, this is not only memory safe, but is also
safe for concurrency).

I also intend to implement the following:

  • region-based memory allocation (this is going to be similar to the pool
    allocator above, but different types will be allocated, and the most
    pressing concern for me is that of proper alignment)
  • reference-counting for the pool / region allocators (so-called
    "group-based" reference counting: basically, pointers within the group may
    form as complex cycles as needed)
  • probably some schemes where pointers that are taken out of the allocator
    are linear (e.g. for a very simple pool allocator with O(1) (de)allocation)

There’s hoping somebody will find this useful as well.

Ever looked at MPS? http://www.ravenbrook.com/project/mps/