Reading List

The Selfish Gene
The Psychopath Test: A Journey Through the Madness Industry
Bad Science
The Feynman Lectures on Physics
The Theory of Everything: The Origin and Fate of the Universe


ifknot's favorite books »
Showing posts with label pattern. Show all posts
Showing posts with label pattern. Show all posts

Wednesday, 3 September 2014

C++11 Variadic template factory member function fun! Building a FBP directed graph class.

Better by variadic design?


TL;DR The libfbp library needs a directed graph container for the ensemble of communicating components that makes FBP programming as easy and error free as possible. Achieving these goals by giving the directed graph class the responsibilities for creation, storage, lifetime and execution of its components and connections poses the challenge of how to implement generic factory methods that allow the creation of a zoo of unknowable components and connections?  C++11/14 variadic template metaprogramming to the rescue!

Sunday, 13 April 2014

Static variables in template class results in smart enqueuer-dequeuer pattern.

Decorator pattern[1] tricks to reduce queue dependency


TL;DR this one simple trick for static member initialization in a class template[2].

The original rather dumb enqueuer and dequeuer used the shared_queue class to track their counts and close the underlying queue accordingly. Giving them each their own static count makes the shared_queue wrapper redundant and usage more intuitive, but how to initialise the static variable was a brief head scratcher...