Skip to content

Commit 2fff310

Browse files
Merge branch 'main' into houliston/fix-coverage
2 parents d3d1708 + defb7e9 commit 2fff310

6 files changed

Lines changed: 8 additions & 14 deletions

File tree

src/dsl/store/ThreadStore.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
#ifndef NUCLEAR_DSL_STORE_THREADSTORE_HPP
2424
#define NUCLEAR_DSL_STORE_THREADSTORE_HPP
2525

26-
#include "../../util/platform.hpp"
27-
2826
namespace NUClear {
2927
namespace dsl {
3028
namespace store {
@@ -46,12 +44,12 @@ namespace dsl {
4644
*/
4745
template <typename DataType, int Index = 0>
4846
struct ThreadStore {
49-
static ATTRIBUTE_TLS DataType* value; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
47+
static thread_local DataType* value; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
5048
};
5149

5250
template <typename DataType, int index>
5351
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
54-
ATTRIBUTE_TLS DataType* ThreadStore<DataType, index>::value = nullptr;
52+
thread_local DataType* ThreadStore<DataType, index>::value = nullptr;
5553

5654
} // namespace store
5755
} // namespace dsl

src/dsl/word/TaskScope.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
#include "../../id.hpp"
2626
#include "../../threading/ReactionTask.hpp"
27-
#include "../../util/platform.hpp"
2827

2928
namespace NUClear {
3029
namespace dsl {
@@ -93,12 +92,12 @@ namespace dsl {
9392
private:
9493
/// The current task id that is running
9594
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
96-
static ATTRIBUTE_TLS NUClear::id_t current_task_id;
95+
static thread_local NUClear::id_t current_task_id;
9796
};
9897

9998
// Initialise the current task id
10099
template <typename Group> // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
101-
ATTRIBUTE_TLS NUClear::id_t TaskScope<Group>::current_task_id{0};
100+
thread_local NUClear::id_t TaskScope<Group>::current_task_id{0};
102101

103102
} // namespace word
104103
} // namespace dsl

src/threading/ReactionTask.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
#include "../id.hpp"
3131
#include "../message/ReactionStatistics.hpp"
32-
#include "../util/platform.hpp"
3332
#include "Reaction.hpp"
3433

3534
namespace NUClear {
@@ -95,7 +94,7 @@ namespace threading {
9594

9695
// Initialize our current task
9796
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
98-
ATTRIBUTE_TLS ReactionTask* ReactionTask::current_task = nullptr;
97+
thread_local ReactionTask* ReactionTask::current_task = nullptr;
9998

10099
} // namespace threading
101100
} // namespace NUClear

src/threading/ReactionTask.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "../util/GroupDescriptor.hpp"
3333
#include "../util/Inline.hpp"
3434
#include "../util/ThreadPoolDescriptor.hpp"
35-
#include "../util/platform.hpp"
3635
#include "Reaction.hpp"
3736

3837
namespace NUClear {
@@ -53,7 +52,7 @@ namespace threading {
5352
class ReactionTask {
5453
private:
5554
/// The current task that is being executed by this thread (or nullptr if none is)
56-
static ATTRIBUTE_TLS ReactionTask* current_task; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
55+
static thread_local ReactionTask* current_task; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
5756

5857
public:
5958
/// Type of the functions that ReactionTasks execute

src/threading/scheduler/Pool.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "../../message/ReactionStatistics.hpp"
3737
#include "../../threading/Reaction.hpp"
3838
#include "../../util/Inline.hpp"
39-
#include "../../util/platform.hpp"
4039
#include "../ReactionTask.hpp"
4140
#include "CountingLock.hpp"
4241
#include "Scheduler.hpp"
@@ -283,7 +282,7 @@ namespace threading {
283282

284283
// Initialise the current pool to nullptr if it is not already
285284
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
286-
ATTRIBUTE_TLS Pool* Pool::current_pool = nullptr;
285+
thread_local Pool* Pool::current_pool = nullptr;
287286

288287
} // namespace scheduler
289288
} // namespace threading

src/threading/scheduler/Pool.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ namespace threading {
246246
std::unique_ptr<Lock> pool_idle = nullptr;
247247

248248
/// A thread local pointer to the current pool this thread is running in
249-
static ATTRIBUTE_TLS Pool* current_pool; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
249+
static thread_local Pool* current_pool; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
250250

251251
friend class Scheduler;
252252
};

0 commit comments

Comments
 (0)