LeechCraft
0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
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::SlotClosure
Executes a given functor upon a signal (or a list of signals).
Definition
slotclosure.h:81
LC::Util::WorkerThreadBase::Initialize
virtual void Initialize()=0
LC::Util::WorkerThreadBase::rotateFuncs
void rotateFuncs()
LC::Util::WorkerThreadBase::GetQueueSize
virtual size_t GetQueueSize()
Definition
workerthreadbase.cpp:24
LC::Util::WorkerThreadBase::run
void run() final
Definition
workerthreadbase.cpp:30
LC::Util::WorkerThreadBase::SetPaused
void SetPaused(bool)
Definition
workerthreadbase.cpp:14
LC::Util::WorkerThreadBase::Cleanup
virtual void Cleanup()=0
LC::Util
Definition
icoreproxy.h:34
LC::Util::Filter
Container< T > Filter(const Container< T > &c, F f)
Definition
prelude.h:118
LC::Util::swap
void swap(FDGuard &g1, FDGuard &g2)
Definition
fdguard.cpp:51
slotclosure.h
workerthreadbase.h
src
util
threads
workerthreadbase.cpp
Generated by
1.10.0