MCPcopy Create free account
hub / github.com/NVIDIA/stdexec / main

Function main

examples/server_theme/let_value.cpp:138–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138auto main() -> int
139{
140 // Create a thread pool and get a scheduler from it
141 exec::static_thread_pool pool{8};
142 ex::scheduler auto sched = pool.get_scheduler();
143
144 // Fake a couple of requests
145 for (int i = 0; i < 10; i++)
146 {
147 // The whole flow for transforming incoming requests into responses
148 ex::sender auto snd =
149 // get a sender when a new request comes
150 schedule_request_start(sched, i)
151 // make sure the request is valid; throw if not
152 | ex::let_value(validate_request)
153 // process the request in a function that may be using a different execution context
154 | ex::let_value(handle_request)
155 // If there are errors transform them into proper responses
156 | ex::let_error(error_to_response)
157 // If the flow is cancelled, send back a proper response
158 | ex::let_stopped(stopped_to_response)
159 // write the result back to the client
160 | ex::let_value(send_response)
161 // done
162 ;
163
164 // execute the whole flow asynchronously
165 exec::start_detached(std::move(snd));
166 }
167
168 pool.request_stop();
169
170 return 0;
171}
172
173#else
174

Callers

nothing calls this directly

Calls 3

schedule_request_startFunction · 0.85
get_schedulerMethod · 0.45
request_stopMethod · 0.45

Tested by

no test coverage detected