Created
June 20, 2016 18:34
-
-
Save Naios/3facf9004bd5ea0eda95cb4cc3e9d983 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "TaskScheduler.h" | |
#include "Duration.h" | |
template<typename T, typename P> | |
std::function<void(TaskContext)> ExecuteWhen(T&& task, P&& predicate) { | |
return [=](TaskContext context) { | |
if (predicate()) | |
task(std::move(context)); | |
else | |
context.Repeat(Milliseconds(10)); | |
}; | |
} | |
void test() | |
{ | |
TaskScheduler scheduler; | |
auto task = [](TaskContext) { /*...*/ }; | |
auto predicate = [] { return true /*...*/; }; | |
scheduler.Schedule(Seconds(5), ExecuteWhen(task, predicate)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment