Pages

Thursday, December 27, 2012

Z.C++: augmenting automatic memory management.

The recreational task for yesterday was replacing two non-owned raw pointers in zaimoni::MetaToken with a new type loosely modeled after boost::flyweight, zaimoni::flyweight.  I got a noticeable speedup in the test suites.

Specification
1) reference-counted; when reference count drops to 0, automatic cleanup desired.
2) This use case was C strings (automatic cleanup with free ok), immutable between initial setup and destruction.

This was a natural for boost::flyweight.  Unfortunately, I didn't have the background to immediately understand the boost::flyweight documentation; I ended up prototyping a partial reimplementation to make sure I understood the design decisions, etc. behind boost::flyweight. (Specifically omitted: multi-thread safety.)