Hi developers!
This is part of a bigger application written entirely in C++.
This is my first time developing an application of this size in C++, and also my first time using the Win32 APIs implementation of threading.
So of course I was MEANT to run into errors :).
This is what I wish for it to be:
Be as easy to use/implement as that of Java. - And yet provide the flexibility, possible of a C++ program.
This is what I got so far:
thread.h:
#include <windows.h>
struct RUNNABLE{
virtual void run() = 0;
};
class Thread{
public:
void start(void* ptr){
DWORD thread_id;
HANDLE thr_handl = CreateThread(0, 0, thread_proc, ptr, 0, &thread_id);
handl = &thr_handl;
}
private:
HANDLE *handl;
DWORD WINAPI thread_proc(LPVOID vpParam){
((RUNNABLE*)vpParam)->run();
CloseHandle(handl);
return 0;
}
};
& here's an example implementation to test its few features so far:
class MyObject : RUNNABLE{
virtual void run(){
for(;;){
mdia_deref->draw_text("thread", 0, 0);
dbSync();
}
}
};
MyObject *obj = new MyObject();
Thread thread;
thread.start(obj)
This is the error produced by the compiler (MSVC++ 2008 Express Edition):
error C3867: 'Thread::thread_proc': function call missing argument list; use '&Thread::thread_proc' to create a pointer to member
I don't know how to interpret or patch it up, AT ALL, so help is appreciated :)
Best regards,
Benjamin.