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

jbaldwin / libcoro / 14100227883

27 Mar 2025 06:23AM UTC coverage: 85.793%. First build
14100227883

Pull #297

github

web-flow
Merge 82cb974a8 into 8fc3e2712
Pull Request #297: Add condition_variable

298 of 354 new or added lines in 10 files covered. (84.18%)

1709 of 1992 relevant lines covered (85.79%)

3511021.42 hits per line

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

51.72
/src/default_executor.cpp
1
#include "coro/default_executor.hpp"
2
#include <atomic>
3
#include <memory>
4

5
static std::atomic<coro::default_executor*> s_default_executor = {nullptr};
6

7
#ifdef LIBCORO_FEATURE_NETWORKING
8
coro::io_scheduler::options coro::default_executor::s_io_scheduler_options;
9
#else
10
coro::thread_pool::options coro::default_executor::s_thread_pool_options;
11
#endif
12

13
coro::default_executor* coro::default_executor::instance()
6✔
14
{
15
    auto* result = s_default_executor.load(std::memory_order::acquire);
6✔
16
    if (!result)
6✔
17
    {
18
        auto ptr = std::make_unique<default_executor>();
1✔
19
        if (s_default_executor.compare_exchange_strong(
1✔
20
                result, ptr.get(), std::memory_order::release, std::memory_order::acquire))
21
            result = ptr.release();
1✔
22
    }
1✔
23
    return result;
6✔
24
}
25

26
coro::default_executor::default_executor()
1✔
27
{
28
#ifdef LIBCORO_FEATURE_NETWORKING
29
    m_io_scheduler = io_scheduler::make_shared(s_io_scheduler_options);
1✔
30
#else
31
    m_thread_pool = std::make_shared<thread_pool>(s_thread_pool_options);
32
#endif
33
}
1✔
34

NEW
35
bool coro::default_executor::spawn(coro::task<void>&& task) noexcept
×
36
{
37
#ifdef LIBCORO_FEATURE_NETWORKING
NEW
38
    return m_io_scheduler->spawn(std::move(task));
×
39
#else
40
    return m_thread_pool->spawn(std::move(task));
41
#endif
42
}
43

NEW
44
bool coro::default_executor::resume(std::coroutine_handle<> handle)
×
45
{
46
#ifdef LIBCORO_FEATURE_NETWORKING
NEW
47
    return m_io_scheduler->resume(handle);
×
48
#else
49
    return m_thread_pool->resume(handle);
50
#endif
51
}
52

NEW
53
std::size_t coro::default_executor::size()
×
54
{
55
#ifdef LIBCORO_FEATURE_NETWORKING
NEW
56
    return m_io_scheduler->size();
×
57
#else
58
    return m_thread_pool->size();
59
#endif
60
}
61

NEW
62
bool coro::default_executor::empty()
×
63
{
64
#ifdef LIBCORO_FEATURE_NETWORKING
NEW
65
    return m_io_scheduler->empty();
×
66
#else
67
    return m_thread_pool->empty();
68
#endif
69
}
70

NEW
71
void coro::default_executor::shutdown()
×
72
{
73
#ifdef LIBCORO_FEATURE_NETWORKING
NEW
74
    m_io_scheduler->shutdown();
×
75
#else
76
    m_thread_pool->shutdown();
77
#endif
NEW
78
}
×
79

80
#ifdef LIBCORO_FEATURE_NETWORKING
81
auto coro::default_executor::schedule() -> coro::io_scheduler::schedule_operation
88✔
82
{
83
    return m_io_scheduler->schedule();
88✔
84
}
85
#else
86
auto coro::default_executor::schedule() -> coro::thread_pool::operation
87
{
88
    return m_thread_pool->schedule();
89
}
90
#endif
91

92
#ifdef LIBCORO_FEATURE_NETWORKING
93

NEW
94
void coro::default_executor::set_io_scheduler_options(io_scheduler::options io_scheduler_options)
×
95
{
NEW
96
    s_io_scheduler_options = io_scheduler_options;
×
NEW
97
}
×
98

99
std::shared_ptr<coro::io_scheduler> coro::default_executor::get_io_scheduler()
5✔
100
{
101
    return m_io_scheduler;
5✔
102
}
103

104
#else
105

106
void coro::default_executor::set_thread_pool_options(thread_pool::options thread_pool_options)
107
{
108
    s_thread_pool_options = thread_pool_options;
109
}
110

111
std::shared_ptr<coro::thread_pool> coro::default_executor::get_thread_pool()
112
{
113
    return m_thread_pool;
114
}
115

116
#endif
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