Implement synchronous implementation of async::executor
This commit is contained in:
parent
9600bd96d5
commit
8425900fe0
2 changed files with 61 additions and 0 deletions
26
libs/async/include/psemek/async/synchronous_executor.hpp
Normal file
26
libs/async/include/psemek/async/synchronous_executor.hpp
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <psemek/async/executor.hpp>
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
35
libs/async/source/synchronous_executor.cpp
Normal file
35
libs/async/source/synchronous_executor.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#include <psemek/async/synchronous_executor.hpp>
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue