From 69e73b98b4beb85d0ae624f0697ff18111ff8c4f Mon Sep 17 00:00:00 2001 From: Florian Fischer <florian.fischer@muhq.space> Date: Wed, 22 Sep 2021 17:59:27 +0200 Subject: [PATCH] [CallerEnvironment] Add a new OWNER caller environment The OWNER caller environment can be used when the executed algorithm should be different if the current worker owns the objects it touches. For example a worker reaping completions on a foreign IoContext may use the EMPER callerEnvironment and the worker of the IoContext OWNER. Also implement the stream operator to print caller environments. --- emper/CallerEnvironment.cpp | 20 ++++++++++++++++++++ emper/CallerEnvironment.hpp | 12 +++++++++--- emper/meson.build | 1 + 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 emper/CallerEnvironment.cpp diff --git a/emper/CallerEnvironment.cpp b/emper/CallerEnvironment.cpp new file mode 100644 index 00000000..559b7cbc --- /dev/null +++ b/emper/CallerEnvironment.cpp @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2021 Florian Fischer +#include "CallerEnvironment.hpp" + +#include <iostream> + +#include "Common.hpp" + +auto operator<<(std::ostream& os, const CallerEnvironment& callerEnvironment) -> std::ostream& { + switch (callerEnvironment) { + case OWNER: + return os << "OWNER"; + case EMPER: + return os << "EMPER"; + case ANYWHERE: + return os << "ANYWHERE"; + default: + DIE_MSG("Unknown CallerEnvironment"); + } +} diff --git a/emper/CallerEnvironment.hpp b/emper/CallerEnvironment.hpp index b06fb419..8ba325f1 100644 --- a/emper/CallerEnvironment.hpp +++ b/emper/CallerEnvironment.hpp @@ -1,8 +1,14 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright © 2020 Florian Schmaus +// Copyright © 2020-2021 Florian Schmaus, Florian Fischer #pragma once +#include <iostream> + +/*! Enum representing the different environments where code can be executed */ enum CallerEnvironment { - EMPER, - ANYWHERE, + OWNER, /*!< indicate code executed by the worker owning the object */ + EMPER, /*!< indicate code executed by any worker */ + ANYWHERE, /*!< indicate code executed outside of any worker */ }; + +auto operator<<(std::ostream& os, const CallerEnvironment& callerEnvironment) -> std::ostream&; diff --git a/emper/meson.build b/emper/meson.build index 1faa5629..fbd3e44c 100644 --- a/emper/meson.build +++ b/emper/meson.build @@ -13,6 +13,7 @@ nasm_gen = generator(nasm, emper_asm_objects = nasm_gen.process(emper_asm_sources) emper_cpp_sources = [ + 'CallerEnvironment.cpp', 'Runtime.cpp', 'Emper.cpp', 'Fiber.cpp', -- GitLab