refactor(Core/Misc): add braces and impove codestyle (#6402)

This commit is contained in:
Kargatum
2021-06-25 00:50:18 +07:00
committed by GitHub
parent 33c271cc7c
commit 3c24b511f2
72 changed files with 1486 additions and 401 deletions

View File

@@ -65,7 +65,9 @@ void TaskScheduler::Dispatch(success_t const& callback)
{
// If the validation failed abort the dispatching here.
if (!_predicate())
{
return;
}
// Process all asyncs
while (!_asyncHolder.empty())
@@ -75,13 +77,17 @@ void TaskScheduler::Dispatch(success_t const& callback)
// If the validation failed abort the dispatching here.
if (!_predicate())
{
return;
}
}
while (!_task_holder.IsEmpty())
{
if (_task_holder.First()->_end > _now)
{
break;
}
// Perfect forward the context to the handler
// Use weak references to catch destruction before callbacks.
@@ -92,7 +98,9 @@ void TaskScheduler::Dispatch(success_t const& callback)
// If the validation failed abort the dispatching here.
if (!_predicate())
{
return;
}
}
// On finish call the final callback
@@ -125,9 +133,13 @@ void TaskScheduler::TaskQueue::RemoveIf(std::function<bool(TaskContainer const&)
{
for (auto itr = container.begin(); itr != container.end();)
if (filter(*itr))
{
itr = container.erase(itr);
}
else
{
++itr;
}
}
void TaskScheduler::TaskQueue::ModifyIf(std::function<bool(TaskContainer const&)> const& filter)
@@ -140,7 +152,9 @@ void TaskScheduler::TaskQueue::ModifyIf(std::function<bool(TaskContainer const&)
itr = container.erase(itr);
}
else
{
++itr;
}
container.insert(cache.begin(), cache.end());
}
@@ -153,7 +167,9 @@ bool TaskScheduler::TaskQueue::IsEmpty() const
TaskContext& TaskContext::Dispatch(std::function<TaskScheduler&(TaskScheduler&)> const& apply)
{
if (auto const owner = _owner.lock())
{
apply(*owner);
}
return *this;
}