I have a question that is making loops in my mind.
I'm wrapping a Win32 thread in a class. The class needs:
- a public start() method called to create and launch the thread.
- a protected run() method, wich will be overloaded by task-specific derived classes.
- CreateThread needs a static function, so I have a private static method that calls run() using the pointer passed as the (void*) argument.
So:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
class Thread
{
public:
// Constructor/Destructor
Thread(void);
virtual ~Thread(void);
// Create and run thread
void start(void);
protected:
// Static wrapper for member function
static DWORD WINAPI entryPoint(void* vpThis);
// Main funtion of the thread
virtualvoid run(void) = 0;
};