mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
AsyncTask::is_runnable
This commit is contained in:
parent
c59bfe5459
commit
2266110083
@ -349,6 +349,21 @@ unlock_and_do_task() {
|
||||
return status;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AsyncTask::is_runnable
|
||||
// Access: Protected, Virtual
|
||||
// Description: Override this function to return true if the task can
|
||||
// be successfully executed, false if it cannot. Mainly
|
||||
// intended as a sanity check when attempting to add the
|
||||
// task to a task manager.
|
||||
//
|
||||
// This function is called with the lock held.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool AsyncTask::
|
||||
is_runnable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AsyncTask::do_task
|
||||
// Access: Protected, Virtual
|
||||
|
@ -111,6 +111,7 @@ protected:
|
||||
void jump_to_task_chain(AsyncTaskManager *manager);
|
||||
DoneStatus unlock_and_do_task();
|
||||
|
||||
virtual bool is_runnable();
|
||||
virtual DoneStatus do_task();
|
||||
virtual void upon_birth();
|
||||
virtual void upon_death(bool clean_exit);
|
||||
|
@ -167,6 +167,8 @@ remove_task_chain(const string &name) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AsyncTaskManager::
|
||||
add(AsyncTask *task) {
|
||||
nassertv(task->is_runnable());
|
||||
|
||||
MutexHolder holder(_lock);
|
||||
|
||||
if (task_cat.is_debug()) {
|
||||
|
@ -79,7 +79,7 @@ set_function(PyObject *function) {
|
||||
|
||||
_function = function;
|
||||
Py_INCREF(_function);
|
||||
if (!PyCallable_Check(_function)) {
|
||||
if (_function != Py_None && !PyCallable_Check(_function)) {
|
||||
nassert_raise("Invalid function passed to PythonTask");
|
||||
}
|
||||
}
|
||||
@ -306,6 +306,21 @@ __getattr__(const string &attr_name) const {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PythonTask::is_runnable
|
||||
// Access: Protected, Virtual
|
||||
// Description: Override this function to return true if the task can
|
||||
// be successfully executed, false if it cannot. Mainly
|
||||
// intended as a sanity check when attempting to add the
|
||||
// task to a task manager.
|
||||
//
|
||||
// This function is called with the lock held.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PythonTask::
|
||||
is_runnable() {
|
||||
return _function != Py_None;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PythonTask::do_task
|
||||
// Access: Protected, Virtual
|
||||
|
@ -27,7 +27,7 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA_PIPELINE PythonTask : public AsyncTask {
|
||||
PUBLISHED:
|
||||
PythonTask(PyObject *function, const string &name = string());
|
||||
PythonTask(PyObject *function = Py_None, const string &name = string());
|
||||
virtual ~PythonTask();
|
||||
ALLOC_DELETED_CHAIN(PythonTask);
|
||||
|
||||
@ -48,6 +48,7 @@ PUBLISHED:
|
||||
PyObject *__getattr__(const string &attr_name) const;
|
||||
|
||||
protected:
|
||||
virtual bool is_runnable();
|
||||
virtual DoneStatus do_task();
|
||||
DoneStatus do_python_task();
|
||||
virtual void upon_birth();
|
||||
|
Loading…
x
Reference in New Issue
Block a user