hoitaja: Added state_handler callback for notifying hoitaja about a cells construction or termination.

This commit is contained in:
Michael Mueller
2023-08-07 18:07:49 +02:00
parent 025a7ce667
commit 278fbb2281
2 changed files with 29 additions and 14 deletions

View File

@@ -28,6 +28,8 @@
#include "numa_controller.h"
/* Core Allocator */
#include "core_allocator.h"
/* State Handler */
#include "state_handler.h"
namespace Hoitaja {
@@ -37,11 +39,11 @@ namespace Hoitaja {
}
struct Hoitaja::Main : Genode::Sandbox::State_handler
struct Hoitaja::Main : Genode::Sandbox::State_handler, Hoitaja::State_handler
{
Env &_env;
Habitat _sandbox { _env, *this };
Habitat _sandbox { _env, *this, *this };
Timer::Connection _timer{_env};
@@ -90,8 +92,8 @@ struct Hoitaja::Main : Genode::Sandbox::State_handler
{
//log("Hoitaja's entering its maintance cycle");
// For now just print all cells created by Hoitaja
//_sandbox.maintain_cells();
_timer.trigger_once(1000 * 1000);
//_handle_config();
//_timer.trigger_once(1000 * 1000);
}
Signal_handler<Main> _timeout_handler{
@@ -102,7 +104,8 @@ struct Hoitaja::Main : Genode::Sandbox::State_handler
*/
void handle_sandbox_state() override
{
Genode::log("Habitat state changed");
/*
try {
Reporter::Xml_generator xml(*_reporter, [&] () {
_sandbox.generate_state_report(xml); });
@@ -111,13 +114,19 @@ struct Hoitaja::Main : Genode::Sandbox::State_handler
error("state report exceeds maximum size");
/* try to reflect the error condition as state report */
try to reflect the error condition as state report
try {
Reporter::Xml_generator xml(*_reporter, [&] () {
xml.attribute("error", "report buffer exceeded"); });
}
catch (...) { }
}
}*/
}
void handle_habitat_state(Cell &cell) override
{
Genode::log("Habitat changed");
_sandbox.update(cell);
}
Main(Env &env) : _env(env)
@@ -133,12 +142,5 @@ struct Hoitaja::Main : Genode::Sandbox::State_handler
}
};
void Hoitaja::Habitat::maintain_cells()
{
log("My current children are:");
_children.for_each_child([&](Child &child)
{ log(child.name(), " ram: ", child.ram_quota()); });
}
void Component::construct(Genode::Env &env) { static Hoitaja::Main main(env); }

View File

@@ -0,0 +1,13 @@
#pragma once
#include <util/interface.h>
namespace Hoitaja {
struct State_handler;
class Cell;
}
struct Hoitaja::State_handler : Genode::Interface
{
virtual void handle_habitat_state(Cell &cell) = 0;
};