Index of /code/eloi_pthread/

This is an example of using C++ classes within a C-style callback framework, plus a rudimentary example of using POSIX threads. POSIX threads are available on most Unix platforms, plus Windows via Cygwin.

Do not use this code in any sort of production environment. The Thread class defined here is hardly complete. It doesn't support all thread operations that POSIX threads support; it doesn't even support locking. If you're actually planning on working with threads, it would be best to use a serious, portable, and supported threading library, such as ACE, Boost, GNU Common C++, NSPR, etc.

Caveat haxor.

P.S. Don't forget to link in the POSIX threads library. The mechanism to do this varies from system to system. If you're using g++, it may be as simple as this:

g++ Thread.cpp main.cpp -pthread

(On Cygwin, the -pthread flag elicits a warning, but still works.)

There is also a makefile provided which will build the software for you. If you have Make installed on your system, just run it:

make

If this doesn't work for you, consult your documentation.

NameLast modified
main.cpp 18-May-2010 18:49
Thread.cpp 18-May-2010 18:44
Thread.hpp 18-May-2010 18:48