Threads: Add some undefined constructors etc

This is needed to "get rid" of the C++ default implementation. Yes, I know that
this can be done way nicer with C++11...

Signed-off-by: Uli Schlachter <psychon@znc.in>
StringTest: Make a local function static

Signed-off-by: Uli Schlachter <psychon@znc.in>
Add a ThreadTest to the testsuite

Signed-off-by: Uli Schlachter <psychon@znc.in>
modpython, modperl: Parse all headers

Signed-off-by: Uli Schlachter <psychon@znc.in>
Threads.h: Add some doxygen comments

Signed-off-by: Uli Schlachter <psychon@znc.in>
CThreadPool: Add cancellation support

This adds CThreadPool::cancelJob() and cancelJobs() which can cancel a set of
jobs synchronously. These functions only return when the job was successfully
cancelled.

It tries to cancel the jobs as quickly as possible, skipping any callbacks on
CJob that were not yet called. A job that is already running can use
CJob::wasCancelled() to check if it should quit.

Signed-off-by: Uli Schlachter <psychon@znc.in>
CThreadPool: Fix a race when starting threads

There was a race where threads were themselves responsible for increasing the
counter for the number of running threads. This left an open window where the
thread was already started, but our counter was not yet increased. The effect of
this race would be that we start more threads than we should.

Fix this by increasing the counter before actually starting new worker threads.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Modules: Add a module version of CJob

Signed-off-by: Uli Schlachter <psychon@znc.in>
sample: Add an example for CModuleJob

Signed-off-by: Uli Schlachter <psychon@znc.in>
CJob: Even cancel finished jobs

When a job was cancelled after its runThread() method finished, but before the
main thread noticed this and reacted, we would just run runMain() before and
pretend the job finished normally.

However, with CModuleJob this means that runMain() might get called for a module
which is currently being destructed. This has bad effects with virtual functions
and thus causes problems. It's better to just really cancel the job instead.

Signed-off-by: Uli Schlachter <psychon@znc.in>
CThreadPool::cancelJobs(): Add a comment explaining the logic a bit

Signed-off-by: Uli Schlachter <psychon@znc.in>
Merge pull request #616 from psychon/module-jobs2

Add support for CJob cancellation and necessary module support