4 ms·
So, some friends and I wrote a very basic boilerplate version of something like this ourselves--I intended one day to extend it to use for gamedev tools. Awesom
by angersock 14y ago
So, some friends and I wrote a very basic boilerplate version of something like this ourselves--I intended one day to extend it to use for gamedev tools. Awesome work here!
Would you consider adding a simple way of hooking new/delete and thus having a simple memory allocation tracker? Say, providing a simple way of registering new/delete and then just returning your wrapped versions?
EDIT:
I see you get somewhat close with 'public gamedevwebtools::core::memory::Allocator', but that doesn't seem to be used for what I'd expect--I'd suggest having something like Service::setMallocCallback and Service::setFreeCallback, and then letting the user just call your Service::malloc/Service::free in their own memory management code. Have added ability to pass in line, file, etc. on allocation/deallocation.
EDIT2:
I noticed you do the same once-a-frame business that we did, wherein you call and pump the service message loop.
One thing that we did was have a notion of messages running a command on an object--see the signature here: https://github.com/crertel/headcrab.js/blob/master/inc/headcrab.h#L95 https://github.com/crertel/headcrab.js/blob/master/inc/headc... .
One helpful addition we had was letting you bind pre-function and post-function callbacks and arguments; this made it easy to, for example, call appropriate mutexes and whatnot on an object prior to querying it or mutating it. You may consider adding something similar to that--right now your extensibility seems to be mainly in overriding the on*Message stuff.
Good work again on your project!
- webbedhands 14y agoThanks! I could hook new and delete, and perhaps some other core functions, but I would rather keep the server code minimal and conflict free, so it could be an option which you have to manually enable with a define. The gamedevwebtools::core::memory::Allocator is used internally to provide dynamic memory allocation for the server. I like the idea of setMallocCallback, setFreeCallback and the Service::malloc and free functions as they can provide an easy collection of memory stats. I'll probably add them to the next version. Your object binding system is pretty interesting. I was thinking of adding just service method callback on certain message types, with some sort of internal mapping to map the types to the service methods. But I'll see if I can use a more powerful system.