mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-24 07:46:42 +00:00
parent
3bf050ed30
commit
53eb666ed0
@ -54,6 +54,9 @@ namespace Kernel
|
||||
using Object_identity_reference_list
|
||||
= Genode::List<Object_identity_reference>;
|
||||
|
||||
using Object_identity_list
|
||||
= Genode::List<Kernel::Object_identity>;
|
||||
|
||||
/**
|
||||
* This class represents kernel object's identities including the
|
||||
* corresponding object identity reference for core
|
||||
@ -68,14 +71,15 @@ namespace Kernel
|
||||
}
|
||||
|
||||
|
||||
struct Kernel::Object
|
||||
struct Kernel::Object : public Kernel::Object_identity_list
|
||||
{
|
||||
virtual ~Object() { }
|
||||
virtual ~Object();
|
||||
};
|
||||
|
||||
|
||||
class Kernel::Object_identity
|
||||
: public Kernel::Object_identity_reference_list
|
||||
: public Object_identity_list::Element,
|
||||
public Kernel::Object_identity_reference_list
|
||||
{
|
||||
private:
|
||||
|
||||
@ -88,6 +92,8 @@ class Kernel::Object_identity
|
||||
|
||||
template <typename KOBJECT>
|
||||
KOBJECT * object() { return dynamic_cast<KOBJECT*>(&_object); }
|
||||
|
||||
void invalidate();
|
||||
};
|
||||
|
||||
|
||||
@ -165,8 +171,6 @@ class Kernel::Core_object_identity : public Object_identity,
|
||||
: Object_identity(object),
|
||||
Object_identity_reference(this, *core_pd()) { }
|
||||
|
||||
virtual void destroy() { this->~Object_identity(); }
|
||||
|
||||
capid_t core_capid() { return capid(); }
|
||||
};
|
||||
|
||||
@ -179,11 +183,6 @@ class Kernel::Core_object : public T, public Kernel::Core_object_identity<T>
|
||||
template <typename... ARGS>
|
||||
Core_object(ARGS &&... args)
|
||||
: T(args...), Core_object_identity<T>(*static_cast<T*>(this)) { }
|
||||
|
||||
void destroy() {
|
||||
Core_object_identity<T>::destroy();
|
||||
this->~T();
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _KERNEL__OBJECT_H_ */
|
||||
|
@ -6,16 +6,41 @@
|
||||
|
||||
using namespace Kernel;
|
||||
|
||||
Object_identity::Object_identity(Object & object) : _object(object) { }
|
||||
|
||||
/************
|
||||
** Object **
|
||||
************/
|
||||
|
||||
Object::~Object()
|
||||
{
|
||||
for (Object_identity * oi = first(); oi; oi = first())
|
||||
oi->invalidate();
|
||||
}
|
||||
|
||||
|
||||
Object_identity::~Object_identity()
|
||||
/*********************
|
||||
** Object_identity **
|
||||
*********************/
|
||||
|
||||
void Object_identity::invalidate()
|
||||
{
|
||||
for (Object_identity_reference * oir = first(); oir; oir = first())
|
||||
oir->invalidate();
|
||||
_object.remove(this);
|
||||
}
|
||||
|
||||
|
||||
Object_identity::Object_identity(Object & object)
|
||||
: _object(object) { _object.insert(this); }
|
||||
|
||||
|
||||
Object_identity::~Object_identity() { invalidate(); }
|
||||
|
||||
|
||||
/*******************************
|
||||
** Object_identity_reference **
|
||||
*******************************/
|
||||
|
||||
Object_identity_reference *
|
||||
Object_identity_reference::find(Pd * pd)
|
||||
{
|
||||
@ -50,7 +75,9 @@ Object_identity_reference * Object_identity_reference::factory(void * dst,
|
||||
|
||||
|
||||
void Object_identity_reference::invalidate() {
|
||||
if (_identity) _identity->remove(this); }
|
||||
if (_identity) _identity->remove(this);
|
||||
_identity = nullptr;
|
||||
}
|
||||
|
||||
|
||||
Object_identity_reference::Object_identity_reference(Object_identity *oi,
|
||||
|
Loading…
Reference in New Issue
Block a user