@@ -35,10 +35,13 @@ class RENDER_PIPELINE_DECL FunctionalTask : public AsyncTask
35
35
using TaskFunc = std::function<DoneStatus(FunctionalTask*)>;
36
36
using BirthFunc = std::function<void (FunctionalTask*)>;
37
37
using DeathFunc = std::function<void (FunctionalTask*, bool )>;
38
+ using UserDataType = std::shared_ptr<void >;
38
39
39
40
public:
40
41
FunctionalTask (const TaskFunc& func = nullptr , const std::string& name = {});
42
+ FunctionalTask (const TaskFunc& func, const UserDataType& data, const std::string& name = {});
41
43
FunctionalTask (TaskFunc&& func, const std::string& name = {});
44
+ FunctionalTask (TaskFunc&& func, const UserDataType& data, const std::string& name = {});
42
45
43
46
ALLOC_DELETED_CHAIN (FunctionalTask);
44
47
@@ -56,6 +59,9 @@ class RENDER_PIPELINE_DECL FunctionalTask : public AsyncTask
56
59
void set_upon_death (DeathFunc&& func);
57
60
const DeathFunc& get_upon_death () const ;
58
61
62
+ void set_user_data (const UserDataType& data);
63
+ UserDataType get_user_data () const ;
64
+
59
65
protected:
60
66
bool is_runnable () override ;
61
67
DoneStatus do_task () override ;
@@ -66,6 +72,7 @@ class RENDER_PIPELINE_DECL FunctionalTask : public AsyncTask
66
72
TaskFunc function_;
67
73
BirthFunc upon_birth_;
68
74
DeathFunc upon_death_;
75
+ UserDataType user_data_;
69
76
70
77
public:
71
78
static TypeHandle get_class_type ();
@@ -124,6 +131,16 @@ inline const FunctionalTask::DeathFunc& FunctionalTask::get_upon_death() const
124
131
return upon_death_;
125
132
}
126
133
134
+ inline void FunctionalTask::set_user_data (const UserDataType& data)
135
+ {
136
+ user_data_ = data;
137
+ }
138
+
139
+ inline FunctionalTask::UserDataType FunctionalTask::get_user_data () const
140
+ {
141
+ return user_data_;
142
+ }
143
+
127
144
inline bool FunctionalTask::is_runnable ()
128
145
{
129
146
return bool (function_);
0 commit comments