add thread support based in proposal #398495 by Joseph Winston
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7929 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
cb852a98fd
commit
0fd2fe23cf
16 changed files with 337 additions and 37 deletions
|
|
@ -1,4 +1,4 @@
|
|||
%module(directors="1") director_thread
|
||||
%module(directors="1",threads="1") director_thread
|
||||
|
||||
%{
|
||||
#include <pthread.h>
|
||||
|
|
@ -8,8 +8,8 @@ class Foo;
|
|||
extern "C" void* working(void* t);
|
||||
%}
|
||||
|
||||
|
||||
%feature("director") Foo;
|
||||
%threads;
|
||||
%director Foo;
|
||||
|
||||
%inline {
|
||||
class Foo {
|
||||
|
|
@ -38,7 +38,7 @@ extern "C" void* working(void* t);
|
|||
|
||||
%inline {
|
||||
extern "C" void* working(void* t) {
|
||||
Foo* f = static_cast<Foo*>(t);
|
||||
Foo* f = static_cast<Foo*>(t);
|
||||
while (1) {
|
||||
sleep(1);
|
||||
f->do_foo();
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ d = Derived()
|
|||
d.run()
|
||||
|
||||
if d.val >= 0:
|
||||
print d.val
|
||||
raise RuntimeError
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue