File tree Expand file tree Collapse file tree
include/boost/http_proto/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313#include < boost/http_proto/detail/config.hpp>
1414#include < boost/http_proto/server/router_types.hpp>
1515#include < boost/capy/datastore.hpp>
16+ #include < boost/capy/executor.hpp>
1617#include < boost/capy/task.hpp>
1718#include < boost/http_proto/request.hpp> // VFALCO forward declare?
1819#include < boost/http_proto/request_parser.hpp> // VFALCO forward declare?
@@ -81,6 +82,10 @@ struct BOOST_HTTP_PROTO_SYMBOL_VISIBLE
8182 */
8283 suspender suspend;
8384
85+ /* * Executor associated with the session.
86+ */
87+ capy::executor ex;
88+
8489 /* * Destructor
8590 */
8691 BOOST_HTTP_PROTO_DECL
@@ -176,7 +181,7 @@ struct BOOST_HTTP_PROTO_SYMBOL_VISIBLE
176181 from the route handler.
177182 */
178183 BOOST_HTTP_PROTO_DECL
179- virtual auto spawn (
184+ auto spawn (
180185 capy::task<route_result> coro) ->
181186 route_result;
182187
Original file line number Diff line number Diff line change @@ -56,10 +56,30 @@ set_body(std::string s)
5656auto
5757route_params::
5858spawn (
59- capy::task<route_result>) ->
59+ capy::task<route_result> t ) ->
6060 route_result
6161{
62- detail::throw_invalid_argument ();
62+ return this ->suspend (
63+ [ex = this ->ex , t = std::move (t)](resumer resume) mutable
64+ {
65+ auto h = t.release ();
66+
67+ h.promise ().on_done = [resume, h]()
68+ {
69+ auto & r = h.promise ().result ;
70+ if (r.index () == 2 )
71+ {
72+ auto ep = std::get<2 >(r);
73+ h.destroy ();
74+ std::rethrow_exception (ep);
75+ }
76+ auto rv = std::move (std::get<1 >(r));
77+ h.destroy ();
78+ resume (rv);
79+ };
80+
81+ ex.post ([h]() { h.resume (); });
82+ });
6383}
6484
6585#endif
You can’t perform that action at this time.
0 commit comments