Protect task->refcount by tasks lock

This commit is contained in:
Florian Märkl 2018-11-11 11:05:23 +01:00
parent a5b01f34ab
commit 77d80106e6

View File

@ -231,17 +231,23 @@ R_API void r_core_task_incref (RCoreTask *task) {
if (!task) {
return;
}
TASK_SIGSET_T old_sigset;
tasks_lock_enter (task->core, &old_sigset);
task->refcount++;
tasks_lock_leave (task->core, &old_sigset);
}
R_API void r_core_task_decref (RCoreTask *task) {
if (!task) {
return;
}
TASK_SIGSET_T old_sigset;
tasks_lock_enter (task->core, &old_sigset);
task->refcount--;
if (task->refcount <= 0) {
task_free (task);
}
tasks_lock_leave (task->core, &old_sigset);
}
R_API void r_core_task_schedule(RCoreTask *current, RTaskState next_state) {