LeechCraft
0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
workerthreadbase.cpp
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#include "
workerthreadbase.h
"
10
#include <
util/sll/slotclosure.h
>
11
12
namespace
LC::Util
13
{
14
void
WorkerThreadBase::SetPaused
(
bool
paused)
15
{
16
if
(paused == IsPaused_)
17
return
;
18
19
IsPaused_ = paused;
20
if
(!paused)
21
emit
rotateFuncs
();
22
}
23
24
size_t
WorkerThreadBase::GetQueueSize
()
25
{
26
QMutexLocker locker { &FunctionsMutex_ };
27
return
Functions_.size ();
28
}
29
30
void
WorkerThreadBase::run
()
31
{
32
SlotClosure<NoDeletePolicy>
rotator
33
{
34
[
this
] { RotateFuncs (); },
35
this
,
36
SIGNAL (
rotateFuncs
()),
37
nullptr
38
};
39
40
Initialize
();
41
42
RotateFuncs ();
43
44
QThread::run ();
45
46
Cleanup
();
47
}
48
49
void
WorkerThreadBase::RotateFuncs ()
50
{
51
if
(IsPaused_)
52
return
;
53
54
decltype (Functions_) funcs;
55
56
{
57
QMutexLocker locker { &FunctionsMutex_ };
58
59
using
std::swap
;
60
swap
(funcs, Functions_);
61
}
62
63
for
(
const
auto
& func : funcs)
64
func ();
65
}
66
}
LC::Util::WorkerThreadBase::rotateFuncs
void rotateFuncs()
LC::Util::WorkerThreadBase::SetPaused
void SetPaused(bool)
Definition:
workerthreadbase.cpp:20
LC::Util::WorkerThreadBase::Cleanup
virtual void Cleanup()=0
LC::Util
Definition:
icoreproxy.h:33
LC::Util::swap
void swap(FDGuard &g1, FDGuard &g2)
Definition:
fdguard.cpp:58
slotclosure.h
LC::Util::SlotClosure
Executes a given functor upon a signal (or a list of signals).
Definition:
slotclosure.h:91
LC::Util::WorkerThreadBase::Initialize
virtual void Initialize()=0
workerthreadbase.h
LC::Util::WorkerThreadBase::run
void run() final
Definition:
workerthreadbase.cpp:36
LC::Util::WorkerThreadBase::GetQueueSize
virtual size_t GetQueueSize()
Definition:
workerthreadbase.cpp:30
src
util
threads
workerthreadbase.cpp
Generated by
1.8.17