added net module

This commit is contained in:
2025-06-27 15:19:25 +02:00
parent acd30afe6f
commit cd61ac7f00
39 changed files with 4599 additions and 12 deletions
+48
View File
@@ -0,0 +1,48 @@
#include "matador/net/handler.hpp"
#include <ctime>
namespace matador {
time_t handler::next_timeout() const
{
return next_timeout_;
}
time_t handler::interval() const
{
return interval_;
}
reactor *handler::get_reactor() const
{
return reactor_;
}
void handler::register_reactor(reactor *r)
{
reactor_ = r;
}
void handler::schedule(time_t offset, time_t interval)
{
next_timeout_ = ::time(nullptr) + offset;
interval_ = interval;
}
void handler::cancel_timer()
{
next_timeout_ = 0;
interval_ = 0;
}
void handler::calculate_next_timeout(time_t now)
{
if (interval_ > 0) {
next_timeout_ = now + interval_;
} else {
next_timeout_ = 0;
}
}
}