AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
TaskScheduler::TaskQueue Class Reference

Public Member Functions

void Push (TaskContainer &&task)
 
TaskContainer Pop ()
 Pops the task out of the container. More...
 
TaskContainer const & First () const
 
void Clear ()
 
void RemoveIf (std::function< bool(TaskContainer const &)> const &filter)
 
void ModifyIf (std::function< bool(TaskContainer const &)> const &filter)
 
bool IsGroupQueued (group_t const group)
 Check if the group exists and is currently scheduled. More...
 
bool IsEmpty () const
 

Private Attributes

std::multiset< TaskContainer, Comparecontainer
 

Detailed Description

Member Function Documentation

◆ Clear()

void TaskScheduler::TaskQueue::Clear ( )
145{
146 container.clear();
147}
std::multiset< TaskContainer, Compare > container
Definition: TaskScheduler.h:131

Referenced by TaskScheduler::CancelAll().

◆ First()

auto TaskScheduler::TaskQueue::First ( ) const
140{
141 return *container.begin();
142}

Referenced by TaskScheduler::Dispatch().

◆ IsEmpty()

bool TaskScheduler::TaskQueue::IsEmpty ( ) const
193{
194 return container.empty();
195}

Referenced by TaskScheduler::Dispatch().

◆ IsGroupQueued()

bool TaskScheduler::TaskQueue::IsGroupQueued ( group_t const  group)

Check if the group exists and is currently scheduled.

180{
181 for (auto const& task : container)
182 {
183 if (task->IsInGroup(group))
184 {
185 return true;
186 }
187 }
188
189 return false;
190}

Referenced by TaskScheduler::IsGroupScheduled().

◆ ModifyIf()

void TaskScheduler::TaskQueue::ModifyIf ( std::function< bool(TaskContainer const &)> const &  filter)
163{
164 std::vector<TaskContainer> cache;
165 for (auto itr = container.begin(); itr != container.end();)
166 if (filter(*itr))
167 {
168 cache.push_back(*itr);
169 itr = container.erase(itr);
170 }
171 else
172 {
173 ++itr;
174 }
175
176 container.insert(cache.begin(), cache.end());
177}

Referenced by TaskScheduler::DelayAll(), TaskScheduler::DelayGroup(), TaskScheduler::RescheduleAll(), and TaskScheduler::RescheduleGroup().

◆ Pop()

auto TaskScheduler::TaskQueue::Pop ( )

Pops the task out of the container.

133{
134 TaskContainer result = *container.begin();
135 container.erase(container.begin());
136 return result;
137}
std::shared_ptr< Task > TaskContainer
Definition: TaskScheduler.h:118

Referenced by TaskScheduler::Dispatch().

◆ Push()

void TaskScheduler::TaskQueue::Push ( TaskContainer &&  task)
128{
129 container.insert(task);
130}

References container.

Referenced by TaskScheduler::InsertTask().

◆ RemoveIf()

void TaskScheduler::TaskQueue::RemoveIf ( std::function< bool(TaskContainer const &)> const &  filter)
150{
151 for (auto itr = container.begin(); itr != container.end();)
152 if (filter(*itr))
153 {
154 itr = container.erase(itr);
155 }
156 else
157 {
158 ++itr;
159 }
160}

Referenced by TaskScheduler::CancelGroup().

Member Data Documentation

◆ container

std::multiset<TaskContainer, Compare> TaskScheduler::TaskQueue::container
private

Referenced by Push().