scheduler: add thread_sleep, use const& param
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
146bf14d68
commit
62f31c1436
|
@ -8,7 +8,7 @@ namespace accumulator {
|
|||
|
||||
class EventScheduler {
|
||||
public:
|
||||
virtual void schedule(std::chrono::milliseconds delay_ms) = 0;
|
||||
virtual void schedule(const std::chrono::milliseconds& delay_ms) = 0;
|
||||
|
||||
EventScheduler(const EventScheduler&) = delete;
|
||||
EventScheduler& operator=(const EventScheduler&) = delete;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "event_scheduler.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
namespace fortuna {
|
||||
namespace accumulator {
|
||||
|
@ -15,7 +16,10 @@ private:
|
|||
public:
|
||||
EventSchedulerImpl();
|
||||
|
||||
void schedule(std::chrono::milliseconds delay_ms) override {}
|
||||
void schedule(const std::chrono::milliseconds& delay_ms) override {
|
||||
auto now{std::chrono::system_clock::now()};
|
||||
std::this_thread::sleep_until(now + delay_ms);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace accumulator
|
||||
|
|
Reference in New Issue