-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cpp
34 lines (32 loc) · 1.1 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <basync/future.hpp>
#include <iostream>
#include <thread>
#include <vector>
int main()
{
auto f = basync::async([] {
std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::cout << " " << std::flush;
std::this_thread::sleep_for(std::chrono::seconds(2));
return "World";
});
auto x = std::move(f).then([](auto f) {
std::cout << std::move(f).get() << std::flush;
std::this_thread::sleep_for(std::chrono::milliseconds(200));
return '!';
});
std::cout << "Hello" << std::flush
<< std::move(basync::when_all([&x] {
std::vector<basync::future<char> > v;
v.emplace_back(std::move(x));
return v;
}())
.get()
.at(0))
.get()
<< '\n';
basync::async([] { std::this_thread::sleep_for(std::chrono::milliseconds(750)); })
.then([](auto) { std::cout << "Mooh!\n"; })
.get();
std::cout << [] { return basync::promise<const char*>().get_future(); }().get() << '\n';
}