trantor
Non-blocking I/O cross-platform TCP network library, using C++14
Toggle main menu visibility
Loading...
Searching...
No Matches
SerialTaskQueue.h
1
14
15
#pragma once
16
17
#include "
TaskQueue.h
"
18
#include <
trantor/net/EventLoopThread.h
>
19
#include <trantor/exports.h>
20
#include <string>
21
#include <queue>
22
#include <mutex>
23
#include <atomic>
24
namespace
trantor
25
{
31
class
TRANTOR_EXPORT SerialTaskQueue :
public
TaskQueue
32
{
33
public
:
39
virtual
void
runTaskInQueue
(
const
std::function<
void
()> &task);
40
virtual
void
runTaskInQueue
(std::function<
void
()> &&task);
41
47
virtual
std::string
getName
()
const
48
{
49
return
queueName_;
50
};
51
56
void
waitAllTasksFinished
();
57
58
SerialTaskQueue() =
delete
;
59
65
explicit
SerialTaskQueue
(
const
std::string &name);
66
67
virtual
~SerialTaskQueue();
68
69
/* clang-format off */
77
[[deprecated(
"Use isRunningTask instead"
)]]
78
bool
isRuningTask
()
79
{
80
return
isRunningTask
();
81
}
82
/* clang-format on */
83
90
bool
isRunningTask
()
91
{
92
return
loopThread_.getLoop()
93
? loopThread_.getLoop()->isCallingFunctions()
94
:
false
;
95
}
96
102
size_t
getTaskCount
();
103
108
void
stop
();
109
110
protected
:
111
std::string queueName_;
112
EventLoopThread
loopThread_;
113
bool
stop_{
false
};
114
};
115
}
// namespace trantor
EventLoopThread.h
TaskQueue.h
trantor::EventLoopThread
This class represents an event loop thread.
Definition
EventLoopThread.h:33
trantor::SerialTaskQueue::waitAllTasksFinished
void waitAllTasksFinished()
Wait until all tasks in the queue are finished.
trantor::SerialTaskQueue::SerialTaskQueue
SerialTaskQueue(const std::string &name)
Construct a new serial task queue instance.
trantor::SerialTaskQueue::getName
virtual std::string getName() const
Get the name of the queue.
Definition
SerialTaskQueue.h:47
trantor::SerialTaskQueue::isRuningTask
bool isRuningTask()
Check whether a task is running in the queue.
Definition
SerialTaskQueue.h:78
trantor::SerialTaskQueue::stop
void stop()
Stop the queue.
trantor::SerialTaskQueue::isRunningTask
bool isRunningTask()
Check whether a task is running in the queue.
Definition
SerialTaskQueue.h:90
trantor::SerialTaskQueue::runTaskInQueue
virtual void runTaskInQueue(const std::function< void()> &task)
Run a task in the queue.
trantor::SerialTaskQueue::getTaskCount
size_t getTaskCount()
Get the number of tasks in the queue.
trantor::TaskQueue
This class is a pure virtual class that can be implemented as a SerialTaskQueue or a ConcurrentTaskQu...
Definition
TaskQueue.h:29
trantor
Definition
EventLoop.h:34
trantor
utils
SerialTaskQueue.h
Generated by
1.17.0