Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/dsl/store/ThreadStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#ifndef NUCLEAR_DSL_STORE_THREADSTORE_HPP
#define NUCLEAR_DSL_STORE_THREADSTORE_HPP

#include "../../util/platform.hpp"

namespace NUClear {
namespace dsl {
namespace store {
Expand All @@ -46,12 +44,12 @@ namespace dsl {
*/
template <typename DataType, int Index = 0>
struct ThreadStore {
static ATTRIBUTE_TLS DataType* value; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
static thread_local DataType* value; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
};

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

} // namespace store
} // namespace dsl
Expand Down
5 changes: 2 additions & 3 deletions src/dsl/word/TaskScope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#include "../../id.hpp"
#include "../../threading/ReactionTask.hpp"
#include "../../util/platform.hpp"

namespace NUClear {
namespace dsl {
Expand Down Expand Up @@ -93,12 +92,12 @@ namespace dsl {
private:
/// The current task id that is running
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static ATTRIBUTE_TLS NUClear::id_t current_task_id;
static thread_local NUClear::id_t current_task_id;
};

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

} // namespace word
} // namespace dsl
Expand Down
3 changes: 1 addition & 2 deletions src/threading/ReactionTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include "../id.hpp"
#include "../message/ReactionStatistics.hpp"
#include "../util/platform.hpp"
#include "Reaction.hpp"

namespace NUClear {
Expand Down Expand Up @@ -95,7 +94,7 @@ namespace threading {

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

} // namespace threading
} // namespace NUClear
3 changes: 1 addition & 2 deletions src/threading/ReactionTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "../util/GroupDescriptor.hpp"
#include "../util/Inline.hpp"
#include "../util/ThreadPoolDescriptor.hpp"
#include "../util/platform.hpp"
#include "Reaction.hpp"

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

public:
/// Type of the functions that ReactionTasks execute
Expand Down
3 changes: 1 addition & 2 deletions src/threading/scheduler/Pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "../../message/ReactionStatistics.hpp"
#include "../../threading/Reaction.hpp"
#include "../../util/Inline.hpp"
#include "../../util/platform.hpp"
#include "../ReactionTask.hpp"
#include "CountingLock.hpp"
#include "Scheduler.hpp"
Expand Down Expand Up @@ -283,7 +282,7 @@ namespace threading {

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

} // namespace scheduler
} // namespace threading
Expand Down
2 changes: 1 addition & 1 deletion src/threading/scheduler/Pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ namespace threading {
std::unique_ptr<Lock> pool_idle = nullptr;

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

friend class Scheduler;
};
Expand Down
Loading