fix nf7::Thread wasting SyncWorker
This commit is contained in:
parent
0c29b828c4
commit
4f94ea4e3b
@ -57,6 +57,7 @@ class Thread final : public nf7::Context,
|
|||||||
|
|
||||||
std::mutex mtx_;
|
std::mutex mtx_;
|
||||||
bool working_ = false;
|
bool working_ = false;
|
||||||
|
nf7::Env::Time scheduled_;
|
||||||
|
|
||||||
std::atomic<size_t> tasks_done_ = 0;
|
std::atomic<size_t> tasks_done_ = 0;
|
||||||
|
|
||||||
@ -81,12 +82,13 @@ class Thread final : public nf7::Context,
|
|||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> k {mtx_};
|
std::unique_lock<std::mutex> k {mtx_};
|
||||||
if (auto time = q_.next()) {
|
if (auto time = q_.next()) {
|
||||||
working_ = false;
|
if (time <= nf7::Env::Clock::now() || time != scheduled_) {
|
||||||
|
scheduled_ = *time;
|
||||||
env().Exec(exec_, self, [this]() mutable { ExecNext(); }, *time);
|
env().Exec(exec_, self, [this]() mutable { ExecNext(); }, *time);
|
||||||
} else {
|
|
||||||
working_ = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
working_ = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user