sync.hpp
1 #ifndef XXHR_SYNC_HPP
2 #define XXHR_SYNC_HPP
3 
4 #include <xxhr/response.hpp>
5 #include <future>
6 
7 namespace xxhr {
8 
21  struct sync {
22 
23  std::shared_ptr<std::promise<xxhr::Response>> sync_promise
24  = std::make_shared<std::promise<xxhr::Response>>();
25 
26  void operator()(xxhr::Response&& resp) { sync_promise->set_value(resp); };
27 
28  xxhr::Response operator()() { return sync_promise->get_future().get(); };
29  };
30 }
31 
32 #endif
xxhr::sync
Helper object for the non-recommended good old synchronous way of thinking.
Definition: sync.hpp:21
xxhr::Response
Passed to the unary callback xxhr::on_response. Provides access to request Content and Success,...
Definition: response.hpp:18
xxhr
main library namespace
Definition: api.hpp:20