KjellKod-Code & Design Page

KjellKod
More, and newer blog-articles can be found at my blog.


 g2log is a simple,  efficient and easy to understand logger. It comes with logging, design-by-contract CHECK macros and catching and logging of fatal signals such as SIGSEGV (illegal memory access) and SIGFPE (floating point error) and more. It is cross-platform, tested on both Linux and Windows.  It is free and public domain. What separates g2log from other logger utilities is that it is asynchronous. Through the Active Object pattern (see below) with C++11, g2log gets improved performance through being asynchronous.  A  comparison with the pseudo asynchronous  Google glog (v.0.3.1) shows that g2log is much more efficient, especially in a worst case scenario. 
(2011) Last updated  
2011-11-16

Active Object a.k.a Actor is a great design pattern that should be used way more in my opinion. Instead of using raw threads you have them encapsuled in an object. This gives you easy concurrency and good handling of threads that avoids many of the pitfalls of using raw threads (races, etc). I've put together two examples inspired by Herb Sutter's article "Prefer using active objects instead of naked threads". The first Active Object version was made with standard c++ and generic callbacks and the new second Active Object version is made with C++11 features such as std::thread 
(2009) Last updated  2011-11-08


 Have you tried using Signals and Slots? A collegue of mine thought that they had revolutionized his work even more than the use of smart pointers. Check out what's all about, there you can also find own implementation of it ;-) called KSignals
(2007) Last updated  2009-05-27


Using C++11 atomic, to create a thread safe, lock-free, circular queue in C++ for a single producer, single consumer scenario. 
[C++11 atomic queue]. 
Also my old, legacy and non-recommended blog-article. The non-safe, highly platform dependent "C++ hack" solution that could be seen pre-C++11
[C++ hack queue]   
 Last updated 2013, January 2nd


Volatile
Multithreaded Programmer's Best Friend or something to stay away from for thread usage? In 2006 I was inspired by an (2001) article by Andrei Alexandrescu how to use volatile as a type modifier, similar to const. Now I have grown in my understanding of volatile and although it can look attractive for threaded code in my opinion it is almost always a mistake to use it. I have concentrated my findings about volatile and it's usage and "non-usage"

(2007) Last updated  2010-03-20

 

 Qt with Visual Studio 2005 and with Qt code completion, it's possible and it's relatively easy to set up. See my Qt4 and Visual Studio Express 2005 C++ with Qt code completion on how it's done.
(2007) Last updated  2008-01-31


  g2log 

  Active Object c++11
  Active Object c++03

  Signals and Slots

  Lock-Free Circular  FIFO  

 Stay away from Volatile in threaded code?

  Qt with Visual Studio