OpenVPN 3 Core Library
Loading...
Searching...
No Matches
asiostop.hpp
Go to the documentation of this file.
1// OpenVPN -- An application to securely tunnel IP networks
2// over a single port, with support for SSL/TLS-based
3// session authentication and key exchange,
4// packet encryption, packet authentication, and
5// packet compression.
6//
7// Copyright (C) 2012- OpenVPN Inc.
8//
9// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10//
11
12#ifndef OPENVPN_ASIO_ASIOSTOP_H
13#define OPENVPN_ASIO_ASIOSTOP_H
14
15#include <openvpn/io/io.hpp>
16
18
19namespace openvpn {
21{
22 public:
23 AsioStopScope(openvpn_io::io_context &io_context,
24 Stop *stop,
25 std::function<void()> &&method)
26 : Stop::Scope(stop, post_method(io_context, std::move(method)))
27 {
28 }
29
30 private:
31 static std::function<void()> post_method(openvpn_io::io_context &io_context, std::function<void()> &&method)
32 {
33 return [&io_context, method = std::move(method)]()
34 { openvpn_io::post(io_context, std::move(method)); };
35 }
36};
37
38} // namespace openvpn
39
40#endif
static std::function< void()> post_method(openvpn_io::io_context &io_context, std::function< void()> &&method)
Definition asiostop.hpp:31
AsioStopScope(openvpn_io::io_context &io_context, Stop *stop, std::function< void()> &&method)
Definition asiostop.hpp:23
Scope(Stop *stop_arg, std::function< void()> &&method_arg)
Definition stop.hpp:34
Stop *const stop
Definition stop.hpp:76
const std::function< void()> method
Definition stop.hpp:77