Pass Env & as first argument to connection objects

This patch supplements each existing connection type with an new
constructor that is meant to replace the original one. The new
one takes a reference to the component's environment as argument and
thereby does not rely on the presence of the globally accessible
'env()' interface.

The original constructors are marked as deprecated. Once we have
completely abolished the use of the global 'env()', we will remove them.

Fixes #1960
This commit is contained in:
Norman Feske
2016-05-10 17:24:51 +02:00
committed by Christian Helmuth
parent 3361651e9e
commit a7b3072cc2
34 changed files with 813 additions and 172 deletions

View File

@@ -24,6 +24,14 @@ struct Genode::Cpu_connection : Connection<Cpu_session>, Cpu_session_client
{
enum { RAM_QUOTA = 36*1024 };
Capability<Cpu_session> _session(Parent &parent, char const *label,
long priority, Affinity const &affinity)
{
return session(parent, affinity,
"priority=0x%lx, ram_quota=128K, label=\"%s\"",
priority, label);
}
/**
* Constructor
*
@@ -31,14 +39,26 @@ struct Genode::Cpu_connection : Connection<Cpu_session>, Cpu_session_client
* \param priority designated priority of all threads created
* with this CPU session
*/
Cpu_connection(char const *label = "",
long priority = DEFAULT_PRIORITY,
Cpu_connection(Env &env, const char *label = "", long priority = DEFAULT_PRIORITY,
Affinity const &affinity = Affinity())
:
Connection<Cpu_session>(
session(affinity, "priority=0x%lx, ram_quota=%u, label=\"%s\"",
priority, RAM_QUOTA, label)),
Cpu_session_client(cap()) { }
Connection<Cpu_session>(env, _session(env.parent(), label, priority, affinity)),
Cpu_session_client(cap())
{ }
/**
* Constructor
*
* \noapi
* \deprecated Use the constructor with 'Env &' as first
* argument instead
*/
Cpu_connection(const char *label = "", long priority = DEFAULT_PRIORITY,
Affinity const &affinity = Affinity())
:
Connection<Cpu_session>(_session(*env()->parent(), label, priority, affinity)),
Cpu_session_client(cap())
{ }
};
#endif /* _INCLUDE__CPU_SESSION__CONNECTION_H_ */