perpetual: new module for mapping file into memory

Rikki Cattermole via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Mon Aug 17 21:45:57 PDT 2015


On 18/08/2015 6:27 a.m., Sergei Degtiarev wrote:
> I suggests a new module for mapping  files into memory. Instead of
> viewing the file as array of bytes, it directly maps the object onto
> file allowing to handle it as regular in-memory object. The data remain
> persistent after the program exits and may be re-opened and used again
> or shared between processes.
> Dynamic arrays are also supported with some limitations.
> The code is at
> https://github.com/sdegtiarev/phobos/tree/master/std/experimental/perpetual
> Is anybody interested?

What I like about this approach is:
- No memory allocation, yes yuppie!
- Uses what ever your type is you want!
- The type you want is initialized, yuppie

What I don't like:
- Does not allow for calling the constructor on the type should it have one
- Does not map to std.mmfile in any way
- No way to say an offset in the file to start working from (also maybe 
an upper limit for arrays)
- You implement basically everything in std.mmfile all over again

Fix up the things above and maybe with a bit more cleaning up it can go 
into std.mmfile. It's basically a poor mans (de/)serializer which is 
quite a nice thing to have.



More information about the Digitalmars-d-announce mailing list