/home/runner/work/HiCR/HiCR/include/hicr/backends/boost/executionState.hpp Source File

HiCR: /home/runner/work/HiCR/HiCR/include/hicr/backends/boost/executionState.hpp Source File
HiCR
executionState.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2025 Huawei Technologies Co., Ltd.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
24#pragma once
25
26#include <functional>
27#include <hicr/core/definitions.hpp>
31
32namespace HiCR::backend::boost
33{
34
40{
41 public:
42
48 __INLINE__ ExecutionState(const std::shared_ptr<HiCR::ExecutionUnit> &executionUnit, void *const argument = nullptr)
49 : HiCR::ExecutionState(executionUnit)
50 {
51 // Getting up-casted pointer for the execution unit
52 auto e = static_cast<boost::ExecutionUnit *>(executionUnit.get());
53
54 // Getting function to execution from the execution unit
55 const auto &fc = e->getFunction();
56
57 // Starting coroutine containing the function
58 _coroutine.start(fc, argument);
59 }
60
61 protected:
62
63 __INLINE__ void resumeImpl() override { _coroutine.resume(); }
64
65 __INLINE__ void suspendImpl() override { _coroutine.yield(); }
66
67 __INLINE__ bool checkFinalizationImpl() override { return _coroutine.hasFinished(); }
68
69 private:
70
74 boost::Coroutine _coroutine;
75};
76
77} // namespace HiCR::backend::boost
This file implements the execution unit class for the Boost backend.
Definition executionState.hpp:38
Definition coroutine.hpp:40
__INLINE__ void resume()
Definition coroutine.hpp:54
__INLINE__ void start(const coroutineFc_t &fc, void *const arg)
Definition coroutine.hpp:89
__INLINE__ void yield()
Definition coroutine.hpp:69
__INLINE__ bool hasFinished()
Definition coroutine.hpp:123
Definition executionState.hpp:40
__INLINE__ ExecutionState(const std::shared_ptr< HiCR::ExecutionUnit > &executionUnit, void *const argument=nullptr)
Definition executionState.hpp:48
__INLINE__ void suspendImpl() override
Definition executionState.hpp:65
__INLINE__ void resumeImpl() override
Definition executionState.hpp:63
__INLINE__ bool checkFinalizationImpl() override
Definition executionState.hpp:67
Definition executionUnit.hpp:38
__INLINE__ const Coroutine::coroutineFc_t & getFunction() const
Definition executionUnit.hpp:63
Provides a base definition for a HiCR Execution State class.
Provides a definition for the Coroutine class, implemented with Boost context objects.