swig/Examples/test-suite/python/director_thread.i
Marcelo Matus a76884513a minor fixes for valgrind
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7695 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-10-20 11:20:41 +00:00

48 lines
644 B
OpenEdge ABL

%module(directors="1") director_thread
%{
#include <pthread.h>
#include <iostream>
class Foo;
extern "C" void* working(void* t);
%}
%feature("director") Foo;
%inline {
class Foo {
public:
int val;
pthread_t *t;
Foo() : val(0) {
t = new pthread_t;
}
virtual ~Foo() {
delete t;
}
void run() {
pthread_create(t,NULL,working,this);
sleep(5);
}
virtual void do_foo() {
val += 1;
}
};
}
%inline {
extern "C" void* working(void* t) {
Foo* f = static_cast<Foo*>(t);
while (1) {
sleep(1);
f->do_foo();
}
return 0;
}
}