add director+thread case
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7148 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
30bd3c6834
commit
6d2886e308
3 changed files with 12 additions and 5 deletions
|
|
@ -17,6 +17,7 @@ CPP_TEST_CASES += \
|
||||||
callback \
|
callback \
|
||||||
complextest \
|
complextest \
|
||||||
director_stl \
|
director_stl \
|
||||||
|
director_thread \
|
||||||
file_test \
|
file_test \
|
||||||
implicittest \
|
implicittest \
|
||||||
inout \
|
inout \
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,11 @@ extern "C" void* working(void* t);
|
||||||
%inline {
|
%inline {
|
||||||
class Foo {
|
class Foo {
|
||||||
public:
|
public:
|
||||||
virtual ~Foo() {}
|
int val;
|
||||||
|
Foo() : val(0) {}
|
||||||
|
|
||||||
|
virtual ~Foo() {}
|
||||||
|
|
||||||
void run() {
|
void run() {
|
||||||
pthread_t *t = new pthread_t;
|
pthread_t *t = new pthread_t;
|
||||||
pthread_create(t,NULL,working,this);
|
pthread_create(t,NULL,working,this);
|
||||||
|
|
@ -23,7 +26,7 @@ extern "C" void* working(void* t);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void do_foo() {
|
virtual void do_foo() {
|
||||||
std::cout << "foo" << std::endl;
|
val += 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -33,7 +36,6 @@ extern "C" void* working(void* t);
|
||||||
Foo* f = static_cast<Foo*>(t);
|
Foo* f = static_cast<Foo*>(t);
|
||||||
while (1) {
|
while (1) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
std::cout << "invoked" << std::endl;
|
|
||||||
f->do_foo();
|
f->do_foo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,13 @@ from director_thread import Foo
|
||||||
class Derived(Foo) :
|
class Derived(Foo) :
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Foo.__init__(self)
|
Foo.__init__(self)
|
||||||
print "too"
|
|
||||||
def do_foo(self):
|
def do_foo(self):
|
||||||
print "at drived class"
|
self.val -= 1
|
||||||
|
|
||||||
|
|
||||||
d = Derived()
|
d = Derived()
|
||||||
d.run()
|
d.run()
|
||||||
|
|
||||||
|
if d.val >= 0:
|
||||||
|
raise RuntimeError
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue