-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
40 lines (32 loc) · 1.06 KB
/
main.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
35
36
37
38
39
40
#include <iostream>
#include <iterator>
#include "drivers/RandomGetter.hpp"
#include "drivers/RandomHttpGetter.hpp"
#include "drivers/RandomGenerator.hpp"
#include <boost/coroutine2/all.hpp>
#include <boost/asio/io_context.hpp>
//https://github.com/boostorg/beast/blob/develop/example/http/client/async-ssl/http_client_async_ssl.cpp
typedef boost::coroutines2::coroutine<void> coro_t;
int main()
{
boost::asio::io_context ioc;
coro_t::pull_type printRandomNumber(
[&ioc, &printRandomNumber](coro_t::push_type& yield)
{
RandomGetter rg{ioc, yield, printRandomNumber};
auto result = rg.get();
if (result != -1)
{
std::cout << "RN FETCHED FROM RANDOM.ORG: " << result << "\n";
}
else
{
RandomGenerator rng{ioc, yield, printRandomNumber};
std::cout << "FALLING BACK, RNG: " << rng.get() << "\n";
}
});
std::cout << "CALLING IOC::RUN\n";
ioc.run();
std::cout << "GOODBYE\n";
return 0;
}