std library hooks
Manu
turkeyman at gmail.com
Sun Apr 8 17:59:21 PDT 2012
So one thing that almost every major middleware provides, is an interface
to hook your own allocation and filesystem callbacks under the hood, to
allow integration with your potentially complex technology.
In my industry, memory and filesystem hooks are non-negotiable. We can't
use any middleware that does not provide them.
Traditionally, we have a problem with the C library, and many core C libs
which depend heavily on the CRT. Almost all games engines have to
wastefully rewrite large portions of the CRT, just to implement the
appropriate memory and filesystem interface, and some super handy common
libs are lost to us due to lack of this foresight.
So this in mind, many of the goodies in phobos are currently unusable to us
(although fortunately source is available).
Has it ever been considered to allow hooks into the backends of those
systems which could be registered at runtime?
It would be simple to provide an API where you could register the
filesystem primitives, which all standard libraries would then magically
route through (huzzah!).
A primitive malloc/free hook would be nice to have too, that way we can
direct memory to the appropriate locations, and keep mem stats along with
the the rest of the system.
It's not uncommon to malloc the entire heap on boot, and implement our own
heap management through our own API's. Obviously system functions would
fail to allocate memory in this environment...
Having these hooks in phobos would also lift this burden off of library
developers (usually only added on request with a few months turn around
time, which is no good for project scheduling), and it would never prevent
us access to those libraries where the developers never considered our use
case.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120409/c22a86e9/attachment-0001.html>
More information about the Digitalmars-d
mailing list