Merge branch 'azerothcore:master' into Playerbot

This commit is contained in:
ZhengPeiRu21
2023-04-18 09:28:55 -06:00
committed by GitHub
21 changed files with 434 additions and 220 deletions

View File

@@ -107,6 +107,11 @@ void TaskScheduler::Dispatch(success_t const& callback)
callback();
}
bool TaskScheduler::IsGroupScheduled(group_t const group)
{
return _task_holder.IsGroupQueued(group);
}
void TaskScheduler::TaskQueue::Push(TaskContainer&& task)
{
container.insert(task);
@@ -159,6 +164,19 @@ void TaskScheduler::TaskQueue::ModifyIf(std::function<bool(TaskContainer const&)
container.insert(cache.begin(), cache.end());
}
bool TaskScheduler::TaskQueue::IsGroupQueued(group_t const group)
{
for (auto const& task : container)
{
if (task->IsInGroup(group))
{
return true;
}
}
return false;
}
bool TaskScheduler::TaskQueue::IsEmpty() const
{
return container.empty();

View File

@@ -136,6 +136,9 @@ class TaskScheduler
void ModifyIf(std::function<bool(TaskContainer const&)> const& filter);
/// Check if the group exists and is currently scheduled.
bool IsGroupQueued(group_t const group);
bool IsEmpty() const;
};
@@ -260,6 +263,9 @@ public:
/// Hint: Use std::initializer_list for this: "{1, 2, 3, 4}"
TaskScheduler& CancelGroupsOf(std::vector<group_t> const& groups);
/// Check if the group exists and is currently scheduled.
bool IsGroupScheduled(group_t const group);
/// Delays all tasks with the given duration.
template<class _Rep, class _Period>
TaskScheduler& DelayAll(std::chrono::duration<_Rep, _Period> const& duration)