MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / scope_exit

Class scope_exit

examples/server/httplib.h:320–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318// "http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4189".
319
320struct scope_exit {
321 explicit scope_exit(std::function<void(void)> &&f)
322 : exit_function(std::move(f)), execute_on_destruction{true} {}
323
324 scope_exit(scope_exit &&rhs)
325 : exit_function(std::move(rhs.exit_function)),
326 execute_on_destruction{rhs.execute_on_destruction} {
327 rhs.release();
328 }
329
330 ~scope_exit() {
331 if (execute_on_destruction) { this->exit_function(); }
332 }
333
334 void release() { this->execute_on_destruction = false; }
335
336private:
337 scope_exit(const scope_exit &) = delete;
338 void operator=(const scope_exit &) = delete;
339 scope_exit &operator=(scope_exit &&) = delete;
340
341 std::function<void(void)> exit_function;
342 bool execute_on_destruction;
343};
344
345} // namespace detail
346

Callers 4

listen_after_bindMethod · 0.85
listenMethod · 0.85
httplib.hFile · 0.85
send_Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected