Skip to content

Commit acdbdcb

Browse files
authored
Fix async_utils
1 parent 0a8d717 commit acdbdcb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/utils/async_utils.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ ThreadPool<UseDelay>::ThreadPool(size_t threads, basic_string_view<Char> name) {
6161

6262
template<bool UseDelay>
6363
void ThreadPool<UseDelay>::start(size_t threads, basic_string_view<Char> name) {
64+
std::lock_guard lock{m_};
6465
IRS_ASSERT(threads_.empty());
6566
threads_.reserve(threads);
6667
for (size_t i = 0; i != threads; ++i) {
@@ -123,7 +124,8 @@ void ThreadPool<UseDelay>::Work() {
123124
if constexpr (UseDelay) {
124125
auto& top = tasks_.top();
125126
if (top.at > Clock::now()) {
126-
cv_.wait_until(lock, top.at);
127+
auto const at = top.at;
128+
cv_.wait_until(lock, at);
127129
continue;
128130
}
129131
fn = std::move(const_cast<Func&>(top.fn));

0 commit comments

Comments
 (0)