April 12, 2013

C++ posix thread wrapping

Here's a short story on using posix threads and getting them into c++ objects if that's your preferred language. Tutorial link to the C version. Threads info

The following source is my two cents on C++ posix threads. There are two files: thread.h and thread.cpp. They create an inheritable thread class that you can use to implement your specialised threads.

Now if you use the code, remember you'll have to link it against the pthread library (libpthread) do this by adding option -lpthread to your compiler (or in your Makefile| Makefile.am).

Here's some implementation details on how the thread code can be used. It's  available in the incoming_connection.h & incoming_connection.cpp files. But you can't expect to build these directly as there are some files missing.

These files are just for showing the intent of the thread implementation. Have fun! And yes you should sometimes just read code, it's like reading a good book!

No comments: