Skip to content

Instantly share code, notes, and snippets.

@PeterZhizhin
Created June 11, 2017 20:21
Show Gist options
  • Save PeterZhizhin/2a3faadb7afafd54a5004a33f3f5e7c0 to your computer and use it in GitHub Desktop.
Save PeterZhizhin/2a3faadb7afafd54a5004a33f3f5e7c0 to your computer and use it in GitHub Desktop.
#ifdef NOJUDGE
#include <iostream>
#include "test.cpp"
int func(int a, int b)
{
std::this_thread::sleep_for(std::chrono::seconds(1));
return a + b;
}
struct functor
{
void operator()(int v) {
std::cout << v << std::endl;
}
};
int main(int argc, char *argv[])
{
functor f;
async_launch(std::function<int (int, int)>(func), f, 2, 6);
std::this_thread::sleep_for(std::chrono::seconds(2));
return 0;
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment