orbis: remove process list from context & initial serialization support

modernize kenv
add LockableKernelObject utility
This commit is contained in:
DH 2025-10-11 18:06:29 +03:00
parent f71e3410c1
commit 014012c219
22 changed files with 372 additions and 215 deletions

View file

@ -2,6 +2,7 @@
#include "rx/Rc.hpp"
#include "rx/Serializer.hpp"
#include "rx/SharedMutex.hpp"
#include "rx/TypeId.hpp"
#include <cstddef>
#include <memory>
@ -44,6 +45,28 @@ struct KernelObject : KernelObjectBase, StateT {
}
};
template <rx::Serializable StateT>
struct LockableKernelObject : KernelObjectBase, StateT {
mutable rx::shared_mutex mtx;
template <typename... Args>
LockableKernelObject(Args &&...args)
: KernelObjectBase(rx::TypeId::get<StateT>()),
StateT(std::forward<Args>(args)...) {}
virtual void serialize(rx::Serializer &s) const {
std::lock_guard lock(*this);
s.serialize(static_cast<const StateT &>(*this));
}
virtual void deserialize(rx::Deserializer &s) {
s.deserialize(static_cast<StateT &>(*this));
}
void lock() const { mtx.lock(); }
void unlock() const { mtx.unlock(); }
};
namespace detail {
struct StaticObjectCtl {
std::size_t offset = -1ull;