Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
BoostAsioWork.h
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#ifndef SF_BOOST_ASIO_WORK_H
7
#define SF_BOOST_ASIO_WORK_H
8
9
#include <boost/asio/io_context.hpp>
10
11
#include <memory>
12
13
namespace
Skyfire
14
{
15
namespace
Asio
16
{
17
class
IoContextWorkGuard
18
{
19
public
:
20
explicit
IoContextWorkGuard
(boost::asio::io_context& ioContext)
21
:
_executor
(ioContext.get_executor()),
_ownsWork
(true)
22
{
23
_executor
.on_work_started();
24
}
25
26
~IoContextWorkGuard
()
27
{
28
Reset
();
29
}
30
31
void
Reset
()
32
{
33
if
(!
_ownsWork
)
34
return
;
35
36
_ownsWork
=
false
;
37
_executor
.on_work_finished();
38
}
39
40
private
:
41
boost::asio::io_context::executor_type
_executor
;
42
bool
_ownsWork
;
43
44
IoContextWorkGuard
(
IoContextWorkGuard
const
& right) =
delete
;
45
IoContextWorkGuard
&
operator=
(
IoContextWorkGuard
const
& right) =
delete
;
46
};
47
48
inline
std::unique_ptr<IoContextWorkGuard>
MakeIoContextWorkGuard
(boost::asio::io_context& ioContext)
49
{
50
return
std::unique_ptr<IoContextWorkGuard>(
new
IoContextWorkGuard
(ioContext));
51
}
52
53
inline
void
ResetWorkGuard
(std::unique_ptr<IoContextWorkGuard>& workGuard)
54
{
55
if
(workGuard)
56
workGuard->Reset();
57
58
workGuard.reset();
59
}
60
}
61
}
62
63
#endif
Skyfire::Asio::IoContextWorkGuard
Definition
BoostAsioWork.h:18
Skyfire::Asio::IoContextWorkGuard::operator=
IoContextWorkGuard & operator=(IoContextWorkGuard const &right)=delete
Skyfire::Asio::IoContextWorkGuard::~IoContextWorkGuard
~IoContextWorkGuard()
Definition
BoostAsioWork.h:26
Skyfire::Asio::IoContextWorkGuard::_executor
boost::asio::io_context::executor_type _executor
Definition
BoostAsioWork.h:41
Skyfire::Asio::IoContextWorkGuard::IoContextWorkGuard
IoContextWorkGuard(IoContextWorkGuard const &right)=delete
Skyfire::Asio::IoContextWorkGuard::Reset
void Reset()
Definition
BoostAsioWork.h:31
Skyfire::Asio::IoContextWorkGuard::IoContextWorkGuard
IoContextWorkGuard(boost::asio::io_context &ioContext)
Definition
BoostAsioWork.h:20
Skyfire::Asio::IoContextWorkGuard::_ownsWork
bool _ownsWork
Definition
BoostAsioWork.h:42
Skyfire::Asio
Definition
DatabaseQueue.h:18
Skyfire::Asio::ResetWorkGuard
void ResetWorkGuard(std::unique_ptr< IoContextWorkGuard > &workGuard)
Definition
BoostAsioWork.h:53
Skyfire::Asio::MakeIoContextWorkGuard
std::unique_ptr< IoContextWorkGuard > MakeIoContextWorkGuard(boost::asio::io_context &ioContext)
Definition
BoostAsioWork.h:48
Skyfire
Definition
AuthPatchTransfer.h:12
src
server
shared
Threading
BoostAsioWork.h
Generated on
for Project SkyFire Core by
1.17.0