Skip to content
Snippets Groups Projects
Commit c37d6e8c authored by Philipp Spilger's avatar Philipp Spilger
Browse files

feat: Remove SchedulerSignaller

* only running until end time

Depends-On: 23225
Change-Id: I4b45fd7ff263a4876e60d8f0a5e658facf364fa2
parent 31b76437
No related branches found
No related tags found
No related merge requests found
#pragma once
#include "libnux/scheduling/Scheduler.hpp"
#include "libnux/scheduling/SchedulerSignaller.hpp"
#include "libnux/scheduling/Service.hpp"
#include "libnux/scheduling/Timer.hpp"
......@@ -24,13 +24,12 @@ public:
/**
* Scheduler loop.
* \tparam Signaller Scheduler loop control type
* \tparam E Event source types
* \param signaller Scheduler loop control instance
* \param stop_time Time at which to stop execution
* \param event_sources Tuple of references to event sources
*/
template <typename Signaller, typename... E>
void execute(Signaller& signaller, std::tuple<E&...>& event_sources);
template <typename... E>
void execute(time_type stop_time, std::tuple<E&...>& event_sources);
/**
* Get maximal number of elements stored in queue since creation.
......@@ -178,20 +177,14 @@ inline __attribute__((always_inline)) void Scheduler<queue_size>::run_queue_serv
}
template <size_t queue_size>
template <typename Signaller, typename... E>
void Scheduler<queue_size>::execute(Signaller& signaller, std::tuple<E&...>& event_sources)
template <typename... E>
void Scheduler<queue_size>::execute(time_type const stop_time, std::tuple<E&...>& event_sources)
{
scheduler_signal signal = signaller.signal();
while (not(signal == scheduler_exit)) {
if (not(signal == scheduler_wait)) {
if ((signal == scheduler_run) or (signal == scheduler_finish)) {
if (not(signal == scheduler_finish)) {
fetch_events_timed(event_sources, get_time());
}
sort_earliest_first();
run_queue_service();
}
}
signal = signaller.signal();
time_type current_time = get_time();
while (current_time < stop_time) {
fetch_events_timed(event_sources, current_time);
sort_earliest_first();
run_queue_service();
current_time = get_time();
}
}
#pragma once
//#include "libnux/vx/mailbox.h"
#include "libnux/scheduling/types.hpp"
#include "libnux/vx/spr.h"
///**
// * Scheduler loop control that listens on a mailbox address for signals
// * \tparam signal_address Signal address in mailbox
// */
// template <uint32_t signal_address>
// class SchedulerSignallerMailbox
//{
// public:
// /**
// * Get current signal state.
// * \return Signal state
// */
// inline __attribute__((always_inline)) scheduler_signal signal();
//};
//
// template <uint32_t signal_address>
// inline __attribute__((always_inline)) scheduler_signal
// SchedulerSignallerMailbox<signal_address>::signal()
//{
// uint8_t signal = libnux_mailbox_read_u8(signal_address);
// switch (signal) {
// case scheduler_wait:
// return scheduler_wait;
// case scheduler_run:
// return scheduler_run;
// case scheduler_finish:
// return scheduler_finish;
// case scheduler_exit:
// return scheduler_exit;
// // if unknown signal is encountered, wait
// default:
// return scheduler_wait;
// }
// return scheduler_exit; // This should never be called
//}
// scheduler signaller, that:
// waits until start,
// runs from start to finish,
// finishes from finish to stop
// and exits at stop.
class SchedulerSignallerTimer
{
time_type m_start;
time_type m_finish;
time_type m_stop;
public:
SchedulerSignallerTimer(time_type start, time_type finish, time_type stop);
SchedulerSignallerTimer(time_type start, time_type stop);
SchedulerSignallerTimer(time_type stop);
inline __attribute__((always_inline)) scheduler_signal signal();
};
SchedulerSignallerTimer::SchedulerSignallerTimer(time_type start, time_type finish, time_type stop)
{
this->m_start = start;
this->m_finish = finish;
this->m_stop = stop;
}
SchedulerSignallerTimer::SchedulerSignallerTimer(time_type start, time_type stop)
{
this->m_start = start;
this->m_finish = stop;
this->m_stop = stop;
}
SchedulerSignallerTimer::SchedulerSignallerTimer(time_type stop)
{
this->m_start = 0;
this->m_finish = stop;
this->m_stop = stop;
}
inline __attribute__((always_inline)) scheduler_signal SchedulerSignallerTimer::signal()
{
time_type t = get_time();
if (t < this->m_start) {
return scheduler_wait;
} else if (t >= this->m_start and t < this->m_finish) {
return scheduler_run;
} else if (t >= this->m_finish and t < this->m_stop) {
return scheduler_finish;
} else if (t >= this->m_stop) {
return scheduler_exit;
}
return scheduler_exit; // This will never be called.
}
......@@ -19,16 +19,3 @@ struct Event
Service const* service;
time_type deadline;
};
// scheduler signals
enum scheduler_signal
{
// don't do anything except staying alive
scheduler_wait = 0,
// run, i.e. fetch events and execute them
scheduler_run = 1,
// execute events in queue, but don't fetch new ones
scheduler_finish = 2,
// exit execution function
scheduler_exit = 3,
};
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment