#include <concurrent_message_loop.h>
Definition at line 21 of file concurrent_message_loop.h.
◆ ~ConcurrentMessageLoop()
fml::ConcurrentMessageLoop::~ConcurrentMessageLoop |
( |
| ) |
|
|
virtual |
Definition at line 29 of file concurrent_message_loop.cc.
29 {
31 for (auto& worker : workers_) {
33 worker.join();
34 }
35}
#define FML_DCHECK(condition)
◆ ConcurrentMessageLoop()
fml::ConcurrentMessageLoop::ConcurrentMessageLoop |
( |
size_t |
worker_count | ) |
|
|
explicitprotected |
Definition at line 14 of file concurrent_message_loop.cc.
15 : worker_count_(std::max<size_t>(worker_count, 1ul)) {
16 for (
size_t i = 0;
i < worker_count_; ++
i) {
17 workers_.emplace_back([
i,
this]() {
20 WorkerMain();
21 });
22 }
23
24 for (const auto& worker : workers_) {
25 worker_thread_ids_.emplace_back(worker.get_id());
26 }
27}
static void SetCurrentThreadName(const ThreadConfig &config)
static SkString to_string(int n)
The ThreadConfig is the thread info include thread name, thread priority.
◆ Create()
std::shared_ptr< ConcurrentMessageLoop > fml::ConcurrentMessageLoop::Create |
( |
size_t |
worker_count = std::thread::hardware_concurrency() | ) |
|
|
static |
◆ ExecuteTask()
void fml::ConcurrentMessageLoop::ExecuteTask |
( |
const fml::closure & |
task | ) |
|
|
protectedvirtual |
◆ GetTaskRunner()
◆ GetWorkerCount()
size_t fml::ConcurrentMessageLoop::GetWorkerCount |
( |
| ) |
const |
◆ PostTaskToAllWorkers()
void fml::ConcurrentMessageLoop::PostTaskToAllWorkers |
( |
const fml::closure & |
task | ) |
|
Definition at line 125 of file concurrent_message_loop.cc.
125 {
126 if (!task) {
127 return;
128 }
129
130 std::scoped_lock lock(tasks_mutex_);
131 for (const auto& worker_thread_id : worker_thread_ids_) {
132 thread_tasks_[worker_thread_id].emplace_back(task);
133 }
134 tasks_condition_.notify_all();
135}
◆ RunsTasksOnCurrentThread()
bool fml::ConcurrentMessageLoop::RunsTasksOnCurrentThread |
( |
| ) |
|
Definition at line 172 of file concurrent_message_loop.cc.
172 {
173 std::scoped_lock lock(tasks_mutex_);
174 for (const auto& worker_thread_id : worker_thread_ids_) {
175 if (worker_thread_id == std::this_thread::get_id()) {
176 return true;
177 }
178 }
179 return false;
180}
◆ Terminate()
void fml::ConcurrentMessageLoop::Terminate |
( |
| ) |
|
Definition at line 119 of file concurrent_message_loop.cc.
119 {
120 std::scoped_lock lock(tasks_mutex_);
121 shutdown_ = true;
122 tasks_condition_.notify_all();
123}
The documentation for this class was generated from the following files: