Skip to content

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alicealys committed Jul 5, 2021
1 parent 52d07f6 commit c2d5edd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
13 changes: 11 additions & 2 deletions src/component/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ namespace scheduler
});
}

void clear()
{
callbacks_.access([&](task_list& tasks)
{
this->merge_callbacks();
tasks.clear();
});
}

void execute()
{
callbacks_.access([&](task_list& tasks)
Expand Down Expand Up @@ -99,9 +108,9 @@ namespace scheduler
}
}

int get_task_count(const pipeline type)
void clear_tasks(const pipeline type)
{
return pipelines[type].task_count;
return pipelines[type].clear();
}

void schedule(const std::function<bool()>& callback, const pipeline type,
Expand Down
2 changes: 1 addition & 1 deletion src/component/scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace scheduler
static const bool cond_continue = false;
static const bool cond_end = true;

int get_task_count(const pipeline type);
void clear_tasks(const pipeline type);

void schedule(const std::function<bool()>& callback, pipeline type = pipeline::server,
std::chrono::milliseconds delay = 0ms);
Expand Down
5 changes: 1 addition & 4 deletions src/component/scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ namespace scripting

void g_shutdown_game_stub(const int free_scripts)
{
while (scheduler::get_task_count(scheduler::pipeline::async))
{
std::this_thread::sleep_for(10ms);
}
scheduler::clear_tasks(scheduler::pipeline::async);

lua::engine::stop();
g_shutdown_game_hook.invoke<void>(free_scripts);
Expand Down

0 comments on commit c2d5edd

Please sign in to comment.