3939
4040#include < sys/time.h>
4141#include < sys/resource.h>
42+ #include < csignal>
4243
4344namespace bpo = boost::program_options;
4445
@@ -53,6 +54,11 @@ void timer_callback(uv_timer_t*)
5354{
5455 // We simply wake up the event loop. Nothing to be done here.
5556}
57+
58+ void signal_callback (uv_signal_t *, int )
59+ {
60+ // We simply wake up the event loop. Nothing to be done here.
61+ }
5662} // namespace detail
5763
5864struct ExpirationHandlerHelpers {
@@ -78,6 +84,27 @@ struct ExpirationHandlerHelpers {
7884 };
7985 }
8086
87+ static RouteConfigurator::CreationConfigurator signalDrivenConfigurator (InputSpec const & matcher, size_t inputTimeslice, size_t maxInputTimeslices)
88+ {
89+ return [matcher, inputTimeslice, maxInputTimeslices](DeviceState& state, ConfigParamRegistry const & options) {
90+ std::string startName = std::string{" start-value-" } + matcher.binding ;
91+ std::string endName = std::string{" end-value-" } + matcher.binding ;
92+ std::string stepName = std::string{" step-value-" } + matcher.binding ;
93+ auto start = options.get <int64_t >(startName.c_str ());
94+ auto stop = options.get <int64_t >(endName.c_str ());
95+ auto step = options.get <int64_t >(stepName.c_str ());
96+ // We create a timer to wake us up. Notice the actual
97+ // timeslot creation and record expiration still happens
98+ // in a synchronous way.
99+ uv_signal_t * sh = (uv_signal_t *)(malloc (sizeof (uv_signal_t )));
100+ uv_signal_init (state.loop , sh);
101+ uv_signal_start (sh, detail::signal_callback, SIGUSR1);
102+ state.activeSignals .push_back (sh);
103+
104+ return LifetimeHelpers::enumDrivenCreation (start, stop, step, inputTimeslice, maxInputTimeslices);
105+ };
106+ }
107+
81108 static RouteConfigurator::CreationConfigurator enumDrivenConfigurator (InputSpec const & matcher, size_t inputTimeslice, size_t maxInputTimeslices)
82109 {
83110 return [matcher, inputTimeslice, maxInputTimeslices](DeviceState&, ConfigParamRegistry const & options) {
@@ -591,6 +618,12 @@ void DeviceSpecHelpers::processInEdgeActions(std::vector<DeviceSpec>& devices,
591618 ExpirationHandlerHelpers::danglingEnumerationConfigurator (inputSpec),
592619 ExpirationHandlerHelpers::expiringEnumerationConfigurator (inputSpec, sourceChannel)};
593620 break ;
621+ case Lifetime::Signal:
622+ route.configurator = {
623+ ExpirationHandlerHelpers::signalDrivenConfigurator (inputSpec, consumerDevice.inputTimesliceId , consumerDevice.maxInputTimeslices ),
624+ ExpirationHandlerHelpers::danglingEnumerationConfigurator (inputSpec),
625+ ExpirationHandlerHelpers::expiringEnumerationConfigurator (inputSpec, sourceChannel)};
626+ break ;
594627 case Lifetime::Transient:
595628 route.configurator = {
596629 ExpirationHandlerHelpers::dataDrivenConfigurator (),
0 commit comments