Re: [boost] Generic lazy loader library interest

Hey Dave, It is not a code loader (or class loader) in the sense of Java. This is a design pattern which delays execution (allocation) until the object is first needed. Wikipedia would have a much better explanation than I could ( http://en.wikipedia.org/wiki/Lazy_loading). I currently have a example up on my Github repository, but there is still work to be done to make it better so I figured I'd put the feelers out to see if there is interest. I have a post regarding it on my blog (http://thoughtlessbanter.com/) and I'll include a snippet from the example. class Unique{public: Unique() : m_uuid(boost::uuids::random_generator()()) { } Unique(const boost::uuids::uuid& u) : m_uuid(u) { } const boost::uuids::uuid& uuid() { return m_uuid; }private: boost::uuids::uuid m_uuid;}; static void factory(boost::shared_ptr<Unique>& impl){ impl = boost::shared_ptr<Unique>( new Unique(boost::uuids::nil_uuid()) );} int main(int argc, char* argv[]){ thunk::lazy_loader<Unique> loader(&factory); const boost::uuids::uuid& u = loader->uuid(); std::cout<<"uuid: "<<boost::lexical_cast<std::string>(u)<<std::endl; return 0;} Thanks, jb
participants (1)
-
John Bellone