• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jbaldwin / libcoro / 9921718395

05 Jul 2024 06:29PM UTC coverage: 84.498% (+0.9%) from 83.609%
9921718395

push

github

web-flow
coro::thread_pool high cpu usage when tasks < threads (#265)

* coro::thread_pool high cpu usage when tasks < threads

The check for m_size > 0 was keeping threads awake in a spin state until
all tasks completed. This correctl now uses m_queue.size() behind the
lock to correctly only wake up threads on the condition variable when
tasks are waiting to be processed.

* Fix deadlock with task_container and tls::client with the client's
  destructor scheduling a tls cleanup task, the task_container's lock
was being locked twice when the cleanup task was being destroyed.

Closes #262

* Adjust when task_container's user_task is deleted

It is now deleted inline in make_user_task so any destructors that get
invoked that possibly schedule more coroutines do not cause a deadlock

* io_scheduler is now std::enable_shared_from_this

51 of 64 new or added lines in 5 files covered. (79.69%)

51 existing lines in 4 files now uncovered.

1379 of 1632 relevant lines covered (84.5%)

4234968.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.92
/src/sync_wait.cpp
1
#include "coro/sync_wait.hpp"
2

3
namespace coro::detail
4
{
5
sync_wait_event::sync_wait_event(bool initially_set) : m_set(initially_set)
6,000,114✔
6
{
7
}
6,000,114✔
8

9
auto sync_wait_event::set() noexcept -> void
6,000,114✔
10
{
11
    m_set.exchange(true, std::memory_order::release);
6,000,114✔
12
    m_cv.notify_all();
6,000,114✔
13
}
6,000,114✔
14

UNCOV
15
auto sync_wait_event::reset() noexcept -> void
×
16
{
UNCOV
17
    m_set.exchange(false, std::memory_order::release);
×
UNCOV
18
}
×
19

20
auto sync_wait_event::wait() noexcept -> void
6,000,114✔
21
{
22
    std::unique_lock<std::mutex> lk{m_mutex};
6,000,114✔
23
    m_cv.wait(lk, [this] { return m_set.load(std::memory_order::acquire); });
12,000,305✔
24
}
6,000,114✔
25

26
} // namespace coro::detail
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc