OpenVPN 3 Core Library
Loading...
Searching...
No Matches
asiocontext.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_ASIOCONTEXT_H
13
#define OPENVPN_ASIO_ASIOCONTEXT_H
14
15
#include <vector>
16
#include <memory>
17
#include <mutex>
18
19
#include <
openvpn/io/io.hpp
>
20
21
namespace
openvpn
{
22
class
AsioContextStore
23
{
24
public
:
25
openvpn_io::io_context &
new_context
(
int
concurrency_hint)
26
{
27
openvpn_io::io_context *ioc =
new
openvpn_io::io_context(concurrency_hint);
28
{
29
std::lock_guard lock(
mutex
);
30
contexts
.emplace_back(ioc);
31
}
32
return
*ioc;
33
}
34
40
void
stop
()
41
{
42
std::lock_guard lock(
mutex
);
43
44
for
(
auto
&context :
contexts
)
45
context->stop();
46
}
47
48
private
:
49
std::mutex
mutex
;
50
std::vector<std::unique_ptr<openvpn_io::io_context>>
contexts
;
51
};
52
}
// namespace openvpn
53
54
#endif
openvpn::AsioContextStore
Definition
asiocontext.hpp:23
openvpn::AsioContextStore::new_context
openvpn_io::io_context & new_context(int concurrency_hint)
Definition
asiocontext.hpp:25
openvpn::AsioContextStore::stop
void stop()
Definition
asiocontext.hpp:40
openvpn::AsioContextStore::mutex
std::mutex mutex
Definition
asiocontext.hpp:49
openvpn::AsioContextStore::contexts
std::vector< std::unique_ptr< openvpn_io::io_context > > contexts
Definition
asiocontext.hpp:50
io.hpp
openvpn
Definition
ovpncli.cpp:97
openvpn
asio
asiocontext.hpp
Generated by
1.9.8