Checking object is POD

A coworker showed me a neat trick to check at compile time whether a class/struct was POD. va_arg does not allow non-POD arguments to be passed in. He wrote a little compile time check that could be embedded in functions or even the class/struct declarations themselves. This is not portable -it’s worked in g++ 4.6.3 on my linux box, but does not work in VC++ (MSVC++ apparently is quite happy to pass non-POD objects through va_arg.

Read More

IPC with file backed mutexes

A lesser known use of glibc pthread mutexes is to make them file backed and “share” them for purposes of IPC, ie synchronization across not only between threads in a process, but across processes. The pre-agreement is, as usual, a file path.

Read More