Panda3D
pythonTask.I
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 pythonTask.I
10  * @author drose
11  * @date 2008-09-16
12  */
13 
14 /**
15  * Returns the function that is called when the task runs.
16  */
17 INLINE PyObject *PythonTask::
18 get_function() {
19  Py_INCREF(_function);
20  return _function;
21 }
22 
23 /**
24  * Returns the function that is called when the task finishes.
25  */
26 INLINE PyObject *PythonTask::
27 get_upon_death() {
28  Py_INCREF(_upon_death);
29  return _upon_death;
30 }
31 
32 /**
33  * Returns the "owner" object. See set_owner().
34  */
35 INLINE PyObject *PythonTask::
36 get_owner() const {
37  Py_INCREF(_owner);
38  return _owner;
39 }
40 
41 /**
42  * Sets the "result" of this task. This is the value returned from an "await"
43  * expression on this task.
44  * This can only be called while the task is still alive.
45  */
46 INLINE void PythonTask::
47 set_result(PyObject *result) {
48  // Note that we don't call notify_done() here since the done status will be
49  // automatically notified upon the task's completion.
50  nassertv(is_alive());
51  nassertv(!done());
52  nassertv(_exception == nullptr);
53  Py_INCREF(result);
54  Py_XDECREF(_exc_value);
55  _exc_value = result;
56 }