/home/runner/work/HiCR/HiCR/include/hicr/backends/pthreads/instance.hpp Source File

HiCR: /home/runner/work/HiCR/HiCR/include/hicr/backends/pthreads/instance.hpp Source File
HiCR
instance.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 <pthread.h>
27#include <memory>
29
30namespace HiCR::backend::pthreads
31{
32
37{
38 public:
39
47 Instance(const instanceId_t instanceId, const pthread_t pthreadId, const instanceId_t rootInstanceId)
48 : HiCR::Instance(instanceId),
49 _pthreadId(pthreadId),
50 _rootInstanceId(rootInstanceId){};
51
52 ~Instance() = default;
53
54 bool isRootInstance() const override { return getId() == _rootInstanceId; };
55
61 pthread_t getPthreadId() const { return _pthreadId; }
62
63 private:
64
68 const pthread_t _pthreadId;
69
73 const instanceId_t _rootInstanceId;
74};
75} // namespace HiCR::backend::pthreads
Definition instance.hpp:38
__INLINE__ instanceId_t getId() const
Definition instance.hpp:55
uint64_t instanceId_t
Definition instance.hpp:44
Definition instance.hpp:37
bool isRootInstance() const override
Definition instance.hpp:54
Instance(const instanceId_t instanceId, const pthread_t pthreadId, const instanceId_t rootInstanceId)
Definition instance.hpp:47
pthread_t getPthreadId() const
Definition instance.hpp:61
Provides a definition for the HiCR Instance class.