blob: e3b0409816f7c617f2d3a58708c227e723aff884 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "i_scheduled_executor.h"
#include "scheduledexecutor.h"
class FNET_Transport;
namespace proton {
/**
* This class posts Tasks at a regular interval to another executor which runs them.
*/
class ScheduledForwardExecutor : public IScheduledExecutor {
private:
class State;
class Registration;
using Tasks = vespalib::hash_map<uint64_t, std::unique_ptr<State>>;
ScheduledExecutor _scheduler;
Executor & _executor;
std::mutex _lock;
uint64_t _nextKey;
Tasks _taskList;
bool cancel(uint64_t key);
public:
ScheduledForwardExecutor(FNET_Transport& transport, Executor& executor);
~ScheduledForwardExecutor() override;
[[nodiscard]] Handle scheduleAtFixedRate(std::unique_ptr<Executor::Task> task, duration delay, duration interval) override;
};
}
|