Origami butterfly

  • Model: Robert J. Lang’s Butterfly
  • Folded by: Rafał Cieślak
  • Paper size: 36cm (14″) square sheet
  • Model size: 15cm (6″) wing span
  • Paper type: Waxed-tissue-foil¹
  • Folding time: ~5h

Butterfly   Butterfly

Butterfly   Butterfly Read the rest of this entry »

C++11: std::threads managed by a designated class

Recently I have noticed an unobvious problem that may appear when using std::threads as class fields. I believe it is more than likely to meet if one is not careful enough when implementing C++ classes, due to it’s tricky nature. Also, its solution provides an elegant example of what has to be considered when working with threads in object-oriented C++, therefore I decided to share it.

Consider a scenario where we would like to implement a class that represents a particular thread activity. We would like it to:

  • start a new thread it manages when an instance is constructed
  • stop it when it is destructed

I will present the obvious implementation, explain the problem with it, and describe how to deal with it.

Read the rest of this entry »