mirror of
https://github.com/Zygo/bees.git
synced 2025-05-17 21:35:45 +02:00
task: optimize for common case of single following Task
If there is only one Task in the post exec queue, we can simply insert that Task instead of creating a task to hold a post exec queue of one item. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
parent
ecf110f377
commit
b828f14dd1
17
lib/task.cc
17
lib/task.cc
@ -199,12 +199,17 @@ namespace crucible {
|
|||||||
tlcc->m_local_queue.splice(tlcc->m_local_queue.begin(), queue);
|
tlcc->m_local_queue.splice(tlcc->m_local_queue.begin(), queue);
|
||||||
} else {
|
} else {
|
||||||
// We are not executing under a TaskConsumer.
|
// We are not executing under a TaskConsumer.
|
||||||
// Create a new task to wrap our post-exec queue,
|
// If there is only one task, then just insert it at the front of the queue.
|
||||||
// then push it to the front of the global queue using normal locking methods.
|
if (queue.size() == 1) {
|
||||||
TaskStatePtr rescue_task(make_shared<TaskState>("rescue_task", [](){}));
|
TaskMasterState::push_front(queue);
|
||||||
swap(rescue_task->m_post_exec_queue, queue);
|
} else {
|
||||||
TaskQueue tq_one { rescue_task };
|
// If there are multiple tasks, create a new task to wrap our post-exec queue,
|
||||||
TaskMasterState::push_front(tq_one);
|
// then push it to the front of the global queue using normal locking methods.
|
||||||
|
TaskStatePtr rescue_task(make_shared<TaskState>("rescue_task", [](){}));
|
||||||
|
swap(rescue_task->m_post_exec_queue, queue);
|
||||||
|
TaskQueue tq_one { rescue_task };
|
||||||
|
TaskMasterState::push_front(tq_one);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user