Add pointlog2svg utility for the thesis
[numtypysics.git] / Worker.h
blobed7a8e8d622e76f52fa148172a4ae5e0ec973618
1 /*
2 * This file is part of NumptyPhysics
3 * Copyright (C) 2008 Tim Edmonds
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
17 #ifndef WORKER_H
18 #define WORKER_H
20 #include <SDL/SDL.h>
22 class WorkerBase
24 public:
25 WorkerBase( void (*func)(void*) ) { m_func = func; }
26 void start();
27 bool done();
29 private:
30 void (*m_func)(void*);
31 SDL_Thread *m_thread;
34 template< typename A, typename B, typename C >
35 class Worker : public WorkerBase
37 public:
38 typedef void (*F)(A,B,C);
40 Worker( F ff, A aa, B bb, C cc )
41 : f(ff), a(aa), b(bb), c(cc),
42 WorkerBase( worker, this )
45 static void worker( void *s)
47 Worker* self = (Worker*)s;
48 self->f( self->a, self->b, self->c );
50 private:
51 F f; A a; B b; C c;
57 #endif //WORKER_H