Panda3D
panda
src
pipeline
pythonThread.h
Go to the documentation of this file.
1
/**
2
* PANDA 3D SOFTWARE
3
* Copyright (c) Carnegie Mellon University. All rights reserved.
4
*
5
* All use of this software is subject to the terms of the revised BSD
6
* license. You should have received a copy of this license along
7
* with this source code in a file named "LICENSE."
8
*
9
* @file pythonThread.h
10
* @author drose
11
* @date 2007-04-13
12
*/
13
14
#ifndef PYTHONTHREAD_H
15
#define PYTHONTHREAD_H
16
17
#include "
pandabase.h
"
18
19
#include "
thread.h
"
20
21
#ifdef HAVE_PYTHON
22
/**
23
* This class is exposed to Python to allow creation of a Panda thread from
24
* the Python level. It will spawn a thread that executes an arbitrary Python
25
* functor.
26
*/
27
class
PythonThread :
public
Thread
{
28
PUBLISHED:
29
explicit
PythonThread(PyObject *
function
, PyObject *args,
30
const
std::string &name,
const
std::string &sync_name);
31
virtual
~PythonThread();
32
33
BLOCKING PyObject *
join
();
34
35
public
:
36
PyObject *get_args()
const
;
37
void
set_args(PyObject *);
38
39
static
PyObject *call_python_func(PyObject *
function
, PyObject *args);
40
41
PUBLISHED:
42
MAKE_PROPERTY(args, get_args, set_args);
43
44
protected
:
45
virtual
void
thread_main();
46
47
private
:
48
PyObject *_function;
49
PyObject *_args;
50
PyObject *_result;
51
52
public
:
53
static
TypeHandle
get_class_type() {
54
return
_type_handle;
55
}
56
static
void
init_type() {
57
Thread::init_type();
58
register_type
(_type_handle,
"PythonThread"
,
59
Thread::get_class_type());
60
}
61
virtual
TypeHandle
get_type()
const
{
62
return
get_class_type();
63
}
64
virtual
TypeHandle
force_init_type() {init_type();
return
get_class_type();}
65
66
private
:
67
static
TypeHandle
_type_handle;
68
};
69
#endif // HAVE_PYTHON
70
71
#endif
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition:
register_type.I:22
Thread::join
void join()
Blocks the calling process until the thread terminates.
Definition:
thread.I:239
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition:
typeHandle.h:81
Thread
A thread; that is, a lightweight process.
Definition:
thread.h:46
thread.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Generated on Sun Dec 27 2020 13:23:14 for Panda3D by
1.8.20