mirror of
https://github.com/mmueller41/mxtasking.git
synced 2026-01-21 12:42:57 +01:00
Use singleton object for accessing Genode's environment.
This commit is contained in:
@@ -63,7 +63,7 @@ public:
|
||||
EpochManager(const std::uint16_t count_channels, dynamic::Allocator &allocator,
|
||||
util::maybe_atomic<bool> &is_running) noexcept
|
||||
:
|
||||
Thread(*system::Environment::env, Name("EpochManager"), 8192),
|
||||
Thread(*system::Environment::env(), Name("EpochManager"), 8192),
|
||||
_count_channels(count_channels), _is_running(is_running), _allocator(allocator)
|
||||
{
|
||||
}
|
||||
@@ -159,7 +159,7 @@ private:
|
||||
std::atomic<epoch_t> _global_epoch{0U};
|
||||
|
||||
// Genode Timer object, needed for waking up periodically
|
||||
Timer::Connection _timer { *system::Environment::env };
|
||||
Timer::Connection _timer { *system::Environment::env() };
|
||||
|
||||
// Local epochs, one for every channel.
|
||||
alignas(64) std::array<LocalEpoch, tasking::config::max_cores()> _local_epochs;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <base/component.h>
|
||||
#include <libc/component.h>
|
||||
|
||||
namespace mx::system {
|
||||
/**
|
||||
@@ -7,15 +7,24 @@ namespace mx::system {
|
||||
*/
|
||||
class Environment
|
||||
{
|
||||
public:
|
||||
|
||||
private:
|
||||
/**
|
||||
* @return Genode environment capability
|
||||
*
|
||||
*/
|
||||
static Genode::Env *env;
|
||||
Libc::Env *_env;
|
||||
|
||||
|
||||
public:
|
||||
Environment() = default;
|
||||
|
||||
Libc::Env *getenv() { return _env; }
|
||||
void setenv(Libc::Env *env) { Environment::get_instance().setenv(env); }
|
||||
|
||||
static Environment& get_instance() { static Environment env;
|
||||
return env;
|
||||
}
|
||||
|
||||
static Libc::Env *env() { return Environment::get_instance().getenv(); }
|
||||
|
||||
/**
|
||||
* @return True, if NUMA balancing is enabled by the system.
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
/**
|
||||
* @return Number of available cores.
|
||||
*/
|
||||
static std::uint16_t count_cores() { return std::uint16_t(Environment::env->cpu().affinity_space().total());
|
||||
static std::uint16_t count_cores() { return std::uint16_t(Environment::env()->cpu().affinity_space().total());
|
||||
}
|
||||
};
|
||||
} // namespace mx::system
|
||||
Reference in New Issue
Block a user