Skip to content

Commit 8df6ed8

Browse files
committed
Rename coro::facade to coro::default_executor
1 parent cb49cc7 commit 8df6ed8

8 files changed

+33
-33
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ set(LIBCORO_SOURCE_FILES
9191
include/coro/coro.hpp
9292
include/coro/condition_variable.hpp src/condition_variable.cpp
9393
include/coro/event.hpp src/event.cpp
94-
include/coro/facade.hpp src/facade.cpp
94+
include/coro/default_executor.hpp src/default_executor.cpp
9595
include/coro/generator.hpp
9696
include/coro/latch.hpp
9797
include/coro/mutex.hpp src/mutex.cpp

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ struct Params
801801

802802
int main()
803803
{
804-
auto* scheduler = coro::facade::instance();
804+
auto* scheduler = coro::default_executor::instance();
805805
std::vector<coro::task<void>> tasks{};
806806
auto params = std::make_shared<Params>();
807807
params->max_value = 20;

examples/coro_condition_variable.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ struct Params
8989

9090
int main()
9191
{
92-
auto* scheduler = coro::facade::instance();
92+
auto* scheduler = coro::default_executor::instance();
9393
std::vector<coro::task<void>> tasks{};
9494
auto params = std::make_shared<Params>();
9595
params->max_value = 20;

include/coro/condition_variable.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "coro/facade.hpp"
3+
#include "coro/default_executor.hpp"
44
#ifdef LIBCORO_FEATURE_NETWORKING
55
#include "coro/io_scheduler.hpp"
66
#else
@@ -156,7 +156,7 @@ class strategy_based_on_io_scheduler
156156

157157
public:
158158
explicit strategy_based_on_io_scheduler(
159-
std::shared_ptr<io_scheduler> io_scheduler = coro::facade::instance()->get_io_scheduler());
159+
std::shared_ptr<io_scheduler> io_scheduler = coro::default_executor::instance()->get_io_scheduler());
160160

161161
~strategy_based_on_io_scheduler();
162162

include/coro/coro.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
#endif
3131

3232
#include "coro/condition_variable.hpp"
33+
#include "coro/default_executor.hpp"
3334
#include "coro/event.hpp"
34-
#include "coro/facade.hpp"
3535
#include "coro/generator.hpp"
3636
#include "coro/latch.hpp"
3737
#include "coro/mutex.hpp"

include/coro/facade.hpp renamed to include/coro/default_executor.hpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ namespace coro
1010
{
1111

1212
/**
13-
* Facade for universal access to default scheduler or default thread pool.
14-
* This facade supports the concept of coro::concepts::executor.
13+
* Default executor for universal access to default scheduler or default thread pool.
14+
* This coro::default_executor supports the concept of coro::concepts::executor.
1515
*/
16-
class facade
16+
class default_executor
1717
{
1818
public:
19-
facade();
19+
default_executor();
2020

2121
/**
22-
* Getting a single instance of facade per process
23-
* @return single instance of facade
22+
* Getting a single instance of default_executor per process
23+
* @return single instance of default_executor
2424
*/
25-
static facade* instance();
25+
static default_executor* instance();
2626

2727
#ifdef LIBCORO_FEATURE_NETWORKING
2828
[[nodiscard]] auto schedule() -> coro::io_scheduler::schedule_operation;
@@ -54,7 +54,7 @@ class facade
5454

5555
#ifdef LIBCORO_FEATURE_NETWORKING
5656
/**
57-
* Set up default coro::io_scheduler::options before constructing a single instance of the facade
57+
* Set up default coro::io_scheduler::options before constructing a single instance of the default_executor
5858
* @param io_scheduler_options io_scheduler options
5959
*/
6060
static void set_io_scheduler_options(io_scheduler::options io_scheduler_options);
@@ -65,7 +65,7 @@ class facade
6565
std::shared_ptr<io_scheduler> get_io_scheduler();
6666
#else
6767
/**
68-
* Set up default coro::thread_pool::options before constructing a single instance of the facade
68+
* Set up default coro::thread_pool::options before constructing a single instance of the default_executor
6969
* @param thread_pool_options thread_pool options
7070
*/
7171
static void set_thread_pool_options(thread_pool::options thread_pool_options);

src/facade.cpp renamed to src/default_executor.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
#include "coro/facade.hpp"
1+
#include "coro/default_executor.hpp"
22
#include <atomic>
33
#include <memory>
44

5-
static std::atomic<coro::facade*> s_facade = {nullptr};
5+
static std::atomic<coro::default_executor*> s_facade = {nullptr};
66

77
#ifdef LIBCORO_FEATURE_NETWORKING
8-
coro::io_scheduler::options coro::facade::s_io_scheduler_options;
8+
coro::io_scheduler::options coro::default_executor::s_io_scheduler_options;
99
#else
1010
coro::thread_pool::options coro::facade::s_thread_pool_options;
1111
#endif
1212

13-
coro::facade* coro::facade::instance()
13+
coro::default_executor* coro::default_executor::instance()
1414
{
1515
auto* result = s_facade.load(std::memory_order::acquire);
1616
if (!result)
1717
{
18-
auto ptr = std::make_unique<facade>();
18+
auto ptr = std::make_unique<default_executor>();
1919
if (s_facade.compare_exchange_strong(result, ptr.get(), std::memory_order::release, std::memory_order::acquire))
2020
result = ptr.release();
2121
}
2222
return result;
2323
}
2424

25-
coro::facade::facade()
25+
coro::default_executor::default_executor()
2626
{
2727
#ifdef LIBCORO_FEATURE_NETWORKING
2828
m_io_scheduler = io_scheduler::make_shared(s_io_scheduler_options);
@@ -31,7 +31,7 @@ coro::facade::facade()
3131
#endif
3232
}
3333

34-
bool coro::facade::spawn(coro::task<void>&& task) noexcept
34+
bool coro::default_executor::spawn(coro::task<void>&& task) noexcept
3535
{
3636
#ifdef LIBCORO_FEATURE_NETWORKING
3737
return m_io_scheduler->spawn(std::move(task));
@@ -40,7 +40,7 @@ bool coro::facade::spawn(coro::task<void>&& task) noexcept
4040
#endif
4141
}
4242

43-
bool coro::facade::resume(std::coroutine_handle<> handle)
43+
bool coro::default_executor::resume(std::coroutine_handle<> handle)
4444
{
4545
#ifdef LIBCORO_FEATURE_NETWORKING
4646
return m_io_scheduler->resume(handle);
@@ -49,7 +49,7 @@ bool coro::facade::resume(std::coroutine_handle<> handle)
4949
#endif
5050
}
5151

52-
std::size_t coro::facade::size()
52+
std::size_t coro::default_executor::size()
5353
{
5454
#ifdef LIBCORO_FEATURE_NETWORKING
5555
return m_io_scheduler->size();
@@ -58,7 +58,7 @@ std::size_t coro::facade::size()
5858
#endif
5959
}
6060

61-
bool coro::facade::empty()
61+
bool coro::default_executor::empty()
6262
{
6363
#ifdef LIBCORO_FEATURE_NETWORKING
6464
return m_io_scheduler->empty();
@@ -67,7 +67,7 @@ bool coro::facade::empty()
6767
#endif
6868
}
6969

70-
void coro::facade::shutdown()
70+
void coro::default_executor::shutdown()
7171
{
7272
#ifdef LIBCORO_FEATURE_NETWORKING
7373
m_io_scheduler->shutdown();
@@ -77,7 +77,7 @@ void coro::facade::shutdown()
7777
}
7878

7979
#ifdef LIBCORO_FEATURE_NETWORKING
80-
auto coro::facade::schedule() -> coro::io_scheduler::schedule_operation
80+
auto coro::default_executor::schedule() -> coro::io_scheduler::schedule_operation
8181
{
8282
return m_io_scheduler->schedule();
8383
}
@@ -90,12 +90,12 @@ auto coro::facade::schedule() -> coro::thread_pool::operation
9090

9191
#ifdef LIBCORO_FEATURE_NETWORKING
9292

93-
void coro::facade::set_io_scheduler_options(io_scheduler::options io_scheduler_options)
93+
void coro::default_executor::set_io_scheduler_options(io_scheduler::options io_scheduler_options)
9494
{
9595
s_io_scheduler_options = io_scheduler_options;
9696
}
9797

98-
std::shared_ptr<coro::io_scheduler> coro::facade::get_io_scheduler()
98+
std::shared_ptr<coro::io_scheduler> coro::default_executor::get_io_scheduler()
9999
{
100100
return m_io_scheduler;
101101
}

test/test_condition_variable.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ TEST_CASE("condition_variable single waiter", "[condition_variable]")
1515

1616
std::cout << "condition_variable single waiter" << std::endl;
1717

18-
auto sched = coro::facade::instance()->get_io_scheduler();
18+
auto sched = coro::default_executor::instance()->get_io_scheduler();
1919
coro::mutex m;
2020
coro::condition_variable cv;
2121

@@ -106,7 +106,7 @@ TEST_CASE("condition_variable one notifier and one waiter", "[condition_variable
106106

107107
struct BaseParams
108108
{
109-
std::shared_ptr<coro::io_scheduler> sched = coro::facade::instance()->get_io_scheduler();
109+
std::shared_ptr<coro::io_scheduler> sched = coro::default_executor::instance()->get_io_scheduler();
110110
coro::mutex m;
111111
coro::condition_variable cv{sched};
112112
};
@@ -156,7 +156,7 @@ TEST_CASE("condition_variable notify_all", "[condition_variable]")
156156

157157
struct BaseParams
158158
{
159-
std::shared_ptr<coro::io_scheduler> sched = coro::facade::instance()->get_io_scheduler();
159+
std::shared_ptr<coro::io_scheduler> sched = coro::default_executor::instance()->get_io_scheduler();
160160
;
161161
coro::mutex m;
162162
coro::condition_variable cv{sched};
@@ -209,7 +209,7 @@ TEST_CASE("condition_variable for thread-safe-queue between producers and consum
209209

210210
struct BaseParams
211211
{
212-
coro::facade* sched = coro::facade::instance();
212+
coro::default_executor* sched = coro::default_executor::instance();
213213
coro::mutex m;
214214
coro::condition_variable cv;
215215
std::atomic_bool cancel{false};

0 commit comments

Comments
 (0)