Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita21b2e4

Browse files
committed
just return from runtime_t::shutdown if no actors
1 parentedf7ba8 commita21b2e4

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

‎lib/runtime.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ runtime_t::runtime_t()
6868
}
6969

7070
runtime_t::~runtime_t() {
71-
m_terminating =true;
71+
terminating_ =true;
7272
// Дождаться, когда все потоки будут удалены
7373
queue_event_.signaled();
7474
no_workers_event_.wait();
7575

76-
m_active =false;
76+
active_ =false;
7777

7878
queue_event_.signaled();
7979
// Stop scheduler's thread.
@@ -271,7 +271,12 @@ void runtime_t::shutdown() {
271271

272272
{
273273
std::lock_guard<std::mutex>g(mutex_);
274-
actors = actors_;
274+
275+
if (actors_.empty()) {
276+
return;
277+
}else {
278+
actors = actors_;
279+
}
275280
}
276281

277282
for (auto ai = actors.cbegin(); ai != actors.cend(); ++ai) {
@@ -355,7 +360,7 @@ void runtime_t::execute() {
355360
}
356361
};
357362

358-
while (m_active) {
363+
while (active_) {
359364
while (!queue_.empty()) {
360365
// Прежде чем извлекать объект из очереди, необходимо проверить,
361366
// что есть вычислительные ресурсы для его обработки
@@ -368,7 +373,8 @@ void runtime_t::execute() {
368373
worker =create_worker();
369374
}else {
370375
// Подождать некоторое время осовобождения какого-нибудь потока
371-
const wait_result result = idle_workers_event_.wait(new_worker_timeout);
376+
const wait_result result =
377+
idle_workers_event_.wait(new_worker_timeout);
372378

373379
worker = workers_.idle.pop();
374380

@@ -395,7 +401,7 @@ void runtime_t::execute() {
395401
}
396402
}
397403

398-
if (m_terminating ||
404+
if (terminating_ ||
399405
(queue_event_.wait(std::chrono::seconds(60)) == wait_result::timeout))
400406
{
401407
generics::stack_t<worker_t>queue(workers_.idle.extract());

‎lib/runtime.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ class runtime_t : public worker_t::callbacks {
109109
/// Currently allocated worker threads.
110110
workers_t workers_;
111111
/// -
112-
std::atomic<bool>m_active{true};
113-
std::atomic<bool>m_terminating{false};
112+
std::atomic<bool>active_{true};
113+
std::atomic<bool>terminating_{false};
114114
/// Scheduler thread.
115115
std::thread m_scheduler;
116116
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp