mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 12:32:56 +01:00
base: redesign object pool using lambda interface
Instead of returning pointers to locked objects via a lookup function, the new object pool implementation restricts object access to functors resp. lambda expressions that are applied to the objects within the pool itself. Fix #884 Fix #1658
This commit is contained in:
committed by
Christian Helmuth
parent
555835c95b
commit
458b4d6fc4
@@ -248,26 +248,29 @@ class Genode::Root_component : public Rpc_object<Typed_root<SESSION_TYPE> >,
|
||||
{
|
||||
if (!args.is_valid_string()) throw Root::Invalid_args();
|
||||
|
||||
typedef typename Object_pool<SESSION_TYPE>::Guard Object_guard;
|
||||
Object_guard s(_ep->lookup_and_lock(session));
|
||||
if (!s) return;
|
||||
_ep->apply(session, [&] (SESSION_TYPE *s) {
|
||||
if (!s) return;
|
||||
|
||||
_upgrade_session(s, args.string());
|
||||
_upgrade_session(s, args.string());
|
||||
});
|
||||
}
|
||||
|
||||
void close(Session_capability session) override
|
||||
void close(Session_capability session_cap) override
|
||||
{
|
||||
SESSION_TYPE * s =
|
||||
dynamic_cast<SESSION_TYPE *>(_ep->lookup_and_lock(session));
|
||||
if (!s) return;
|
||||
SESSION_TYPE * session;
|
||||
|
||||
/* let the entry point forget the session object */
|
||||
_ep->dissolve(s);
|
||||
_ep->apply(session_cap, [&] (SESSION_TYPE *s) {
|
||||
session = s;
|
||||
|
||||
_destroy_session(s);
|
||||
/* let the entry point forget the session object */
|
||||
if (session) _ep->dissolve(session);
|
||||
});
|
||||
|
||||
if (!session) return;
|
||||
|
||||
_destroy_session(session);
|
||||
|
||||
POLICY::release();
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user