Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
LogWorker.cpp
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
#include "
LogWorker.h
"
7
#include "
Threading/BoostAsioThreadGroup.h
"
8
9
#include <mutex>
10
11
struct
LogWorker::Impl
12
{
13
Impl
()
14
:
threadGroup
(),
active
(true)
15
{
16
}
17
18
Skyfire::Asio::IoContextThreadGroup
threadGroup
;
19
std::mutex
queueLock
;
20
bool
active
;
21
};
22
23
LogWorker::LogWorker
()
24
:
m_impl
(new
Impl
)
25
{
26
if
(
m_impl
->threadGroup.Start(1) == -1)
27
m_impl
->active =
false
;
28
}
29
30
LogWorker::~LogWorker
()
31
{
32
{
33
std::lock_guard<std::mutex> guard(
m_impl
->queueLock);
34
m_impl
->active =
false
;
35
}
36
37
m_impl
->threadGroup.DrainAndJoin();
38
}
39
40
int
LogWorker::enqueue
(
LogOperation
* op)
41
{
42
if
(!op)
43
return
-1;
44
45
{
46
std::lock_guard<std::mutex> guard(
m_impl
->queueLock);
47
48
if
(!
m_impl
->active)
49
return
-1;
50
}
51
52
m_impl
->threadGroup.GetExecutor().Post(
53
[op]
54
{
55
op->
call
();
56
delete
op;
57
});
58
59
return
0;
60
}
BoostAsioThreadGroup.h
LogWorker.h
LogOperation
Definition
LogOperation.h:13
LogOperation::call
int call()
Definition
LogOperation.cpp:14
LogWorker::m_impl
std::unique_ptr< Impl > m_impl
Definition
LogWorker.h:30
LogWorker::~LogWorker
~LogWorker()
Definition
LogWorker.cpp:30
LogWorker::enqueue
int enqueue(LogOperation *op)
Definition
LogWorker.cpp:40
LogWorker::LogWorker
LogWorker()
Definition
LogWorker.cpp:23
Skyfire::Asio::IoContextThreadGroup
Definition
BoostAsioThreadGroup.h:23
LogWorker::Impl
Definition
LogWorker.cpp:12
LogWorker::Impl::Impl
Impl()
Definition
LogWorker.cpp:13
LogWorker::Impl::active
bool active
Definition
LogWorker.cpp:20
LogWorker::Impl::threadGroup
Skyfire::Asio::IoContextThreadGroup threadGroup
Definition
LogWorker.cpp:18
LogWorker::Impl::queueLock
std::mutex queueLock
Definition
LogWorker.cpp:19
src
server
shared
Logging
LogWorker.cpp
Generated on
for Project SkyFire Core by
1.17.0