perpetual: new module for mapping file into memory

Sergei Degtiarev via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Aug 18 07:16:27 PDT 2015


On Tuesday, 18 August 2015 at 04:46:10 UTC, Rikki Cattermole 
wrote:
> - Does not allow for calling the constructor on the type should 
> it have one
I plan to implement arguments forwarding to constructor, just 
decided that the concept would be more clear with minimal code. 
Technically, the object is initialized with .init and is in valid 
state.

> - Does not map to std.mmfile in any way
> - You implement basically everything in std.mmfile all over 
> again
Does not need to, there are only two system calls involved and it 
makes no sense to reuse such amount of code.

> - No way to say an offset in the file to start working from 
> (also maybe an upper limit for arrays)
This might be useful in some cases, but in general from my 
experience (I used this utility for several years in C++), it 
downgrades the interface, makes you regarding the data as set of 
bytes rather than an object. It is always possible to wrap up 
everything in a struct, so that working portion is at right 
offset.

> it can go into std.mmfile.
The concept is very different from plain shared memory, 
std.mmfile can be improved with a few lines of code, but it 
wouldn't change the way it's used.

> It's basically a poor mans (de/)serializer.
Not at all, it allows fast access to the data, so it might be 
used as effectively as regular values, and insurance from data 
loss at crash or stop.





More information about the Digitalmars-d-announce mailing list