diff --git a/libs/async/include/psemek/async/synchronous_executor.hpp b/libs/async/include/psemek/async/synchronous_executor.hpp new file mode 100644 index 00000000..45b6fa3f --- /dev/null +++ b/libs/async/include/psemek/async/synchronous_executor.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include + +namespace psemek::async +{ + + struct synchronous_executor + : executor + { + void post(task t) override; + + void post_at(clock::time_point time, task t) override; + + void stop() override; + + void wait() override; + + void wait_for(clock::duration period) override; + + void wait_until(clock::time_point time) override; + + std::size_t task_count() const override; + }; + +} diff --git a/libs/async/source/synchronous_executor.cpp b/libs/async/source/synchronous_executor.cpp new file mode 100644 index 00000000..45eadb09 --- /dev/null +++ b/libs/async/source/synchronous_executor.cpp @@ -0,0 +1,35 @@ +#include + +#include + +namespace psemek::async +{ + + void synchronous_executor::post(task t) + { + t(); + } + + void synchronous_executor::post_at(clock::time_point, task) + { + throw std::runtime_error("synchronous_executor doesn't support executor::post_at"); + } + + void synchronous_executor::stop() + {} + + void synchronous_executor::wait() + {} + + void synchronous_executor::wait_for(clock::duration) + {} + + void synchronous_executor::wait_until(clock::time_point) + {} + + std::size_t synchronous_executor::task_count() const + { + return 0; + } + +}