Fixed some bugs

This commit is contained in:
WolverinDEV 2021-05-09 18:28:26 +02:00
parent d2154a8541
commit 616149d5dd
2 changed files with 28 additions and 0 deletions

View File

@ -513,4 +513,30 @@ void task_executor::executor(std::shared_ptr<executor_context> executor_context)
task_context->notify.wait(task_lock);
}
}
}
void task_executor::print_statistics(const std::function<void(const std::string &)>& println, bool print_task_list) {
println("Executor count: " + std::to_string(this->executors.size()));
std::lock_guard task_lock{this->task_context->mutex};
if(print_task_list) {
println("Tasks (" + std::to_string(this->task_context->task_count) + "):");
{
auto head = this->task_context->task_head;
while(head) {
println(" - " + head->name);
head = head->next;
}
}
println("Recurring task count (" + std::to_string(this->task_context->task_recurring_count) + "):");
{
auto head = this->task_context->task_recurring_head;
while(head) {
println(" - " + head->name);
head = head->next;
}
}
} else {
println("Task count: " + std::to_string(this->task_context->task_count));
println("Recurring task count: " + std::to_string(this->task_context->task_recurring_count));
}
}

View File

@ -51,6 +51,8 @@ namespace ts {
std::string /* name */,
std::chrono::nanoseconds /* interval */,
std::function<void(const std::chrono::system_clock::time_point& /* last scheduled */)> /* callback */);
void print_statistics(const std::function<void(const std::string &)>& /* print function */, bool /* print task list */);
private:
struct task;
struct task_recurring;