Skip to content

Commit

Permalink
Remove redundant inlines
Browse files Browse the repository at this point in the history
  • Loading branch information
TrentHouliston committed Aug 9, 2024
1 parent c68e1b6 commit ad1aa13
Show file tree
Hide file tree
Showing 39 changed files with 131 additions and 138 deletions.
2 changes: 1 addition & 1 deletion src/PowerPlant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class PowerPlant {
template <typename Handler>
struct EmitCaller {
template <typename... Arguments>
static inline auto call(Arguments&&... args)
static auto call(Arguments&&... args)
// THIS IS VERY IMPORTANT, the return type must be dependent on the function call
// otherwise it won't check it's valid in SFINAE (the comma operator does it again!)
-> decltype(Handler::emit(std::forward<Arguments>(args)...), true) {
Expand Down
14 changes: 7 additions & 7 deletions src/dsl/Parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,39 +35,39 @@ namespace dsl {
using DSL = Fusion<Sentence...>;

template <typename... Arguments>
static inline auto bind(const std::shared_ptr<threading::Reaction>& r, Arguments&&... args)
static auto bind(const std::shared_ptr<threading::Reaction>& r, Arguments&&... args)
-> decltype(DSL::template bind<Parse<Sentence...>>(r, std::forward<Arguments>(args)...)) {
return DSL::template bind<Parse<Sentence...>>(r, std::forward<Arguments>(args)...);
}

static inline auto get(threading::ReactionTask& task)
static auto get(threading::ReactionTask& task)
-> decltype(std::conditional_t<fusion::has_get<DSL>::value, DSL, fusion::NoOp>::template get<
Parse<Sentence...>>(task)) {
return std::conditional_t<fusion::has_get<DSL>::value, DSL, fusion::NoOp>::template get<Parse<Sentence...>>(
task);
}

static inline bool precondition(threading::ReactionTask& task) {
static bool precondition(threading::ReactionTask& task) {
return std::conditional_t<fusion::has_precondition<DSL>::value, DSL, fusion::NoOp>::template precondition<
Parse<Sentence...>>(task);
}

static inline int priority(threading::ReactionTask& task) {
static int priority(threading::ReactionTask& task) {
return std::conditional_t<fusion::has_priority<DSL>::value, DSL, fusion::NoOp>::template priority<
Parse<Sentence...>>(task);
}

static inline std::set<util::GroupDescriptor> group(threading::ReactionTask& task) {
static std::set<util::GroupDescriptor> group(threading::ReactionTask& task) {
return std::conditional_t<fusion::has_group<DSL>::value, DSL, fusion::NoOp>::template group<
Parse<Sentence...>>(task);
}

static inline util::ThreadPoolDescriptor pool(threading::ReactionTask& task) {
static util::ThreadPoolDescriptor pool(threading::ReactionTask& task) {
return std::conditional_t<fusion::has_pool<DSL>::value, DSL, fusion::NoOp>::template pool<
Parse<Sentence...>>(task);
}

static inline void postcondition(threading::ReactionTask& task) {
static void postcondition(threading::ReactionTask& task) {
std::conditional_t<fusion::has_postcondition<DSL>::value, DSL, fusion::NoOp>::template postcondition<
Parse<Sentence...>>(task);
}
Expand Down
9 changes: 4 additions & 5 deletions src/dsl/fusion/BindFusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace dsl {
*/
struct Return {
template <typename... Arguments>
static inline auto call(const std::shared_ptr<threading::Reaction>& reaction, Arguments&&... args) {
static auto call(const std::shared_ptr<threading::Reaction>& reaction, Arguments&&... args) {
return Function::template bind<DSL>(reaction, std::forward<Arguments>(args)...);
}
};
Expand All @@ -60,16 +60,15 @@ namespace dsl {
*/
struct NoReturn {
template <typename... Arguments>
static inline std::tuple<> call(const std::shared_ptr<threading::Reaction>& reaction,
Arguments&&... args) {
static std::tuple<> call(const std::shared_ptr<threading::Reaction>& reaction, Arguments&&... args) {
Function::template bind<DSL>(reaction, std::forward<Arguments>(args)...);
return {};
}
};


template <typename... Arguments>
static inline auto call(const std::shared_ptr<threading::Reaction>& reaction, Arguments&&... args)
static auto call(const std::shared_ptr<threading::Reaction>& reaction, Arguments&&... args)
-> decltype(std::conditional_t<std::is_void<decltype(Function::template bind<DSL>(
reaction,
std::forward<Arguments>(args)...))>::value,
Expand Down Expand Up @@ -125,7 +124,7 @@ namespace dsl {
struct BindFuser<std::tuple<Word1, WordN...>> {

template <typename DSL, typename... Arguments>
static inline auto bind(const std::shared_ptr<threading::Reaction>& reaction, Arguments&&... args)
static auto bind(const std::shared_ptr<threading::Reaction>& reaction, Arguments&&... args)
-> decltype(util::FunctionFusion<std::tuple<Word1, WordN...>,
decltype(std::forward_as_tuple(reaction,
std::forward<Arguments>(args)...)),
Expand Down
4 changes: 2 additions & 2 deletions src/dsl/fusion/GetFusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace dsl {
*/
template <typename Function, typename DSL>
struct GetCaller {
static inline auto call(threading::ReactionTask& task) -> decltype(Function::template get<DSL>(task)) {
static auto call(threading::ReactionTask& task) -> decltype(Function::template get<DSL>(task)) {
return Function::template get<DSL>(task);
}
};
Expand Down Expand Up @@ -86,7 +86,7 @@ namespace dsl {
struct GetFuser<std::tuple<Word1, WordN...>> {

template <typename DSL, typename U = Word1>
static inline auto get(threading::ReactionTask& task)
static auto get(threading::ReactionTask& task)
-> decltype(util::FunctionFusion<std::tuple<Word1, WordN...>,
decltype(std::forward_as_tuple(task)),
GetCaller,
Expand Down
4 changes: 2 additions & 2 deletions src/dsl/fusion/GroupFusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace dsl {
struct GroupFuser<std::tuple<Word>> {

template <typename DSL>
static inline std::set<util::GroupDescriptor> group(threading::ReactionTask& task) {
static std::set<util::GroupDescriptor> group(threading::ReactionTask& task) {

// Return our group
return Word::template group<DSL>(task);
Expand All @@ -90,7 +90,7 @@ namespace dsl {
struct GroupFuser<std::tuple<Word1, Word2, WordN...>> {

template <typename DSL>
static inline std::set<util::GroupDescriptor> group(threading::ReactionTask& task) {
static std::set<util::GroupDescriptor> group(threading::ReactionTask& task) {
// Merge the list of groups together
std::set<util::GroupDescriptor> groups = Word1::template group<DSL>(task);
auto remainder = GroupFuser<std::tuple<Word2, WordN...>>::template group<DSL>(task);
Expand Down
14 changes: 7 additions & 7 deletions src/dsl/fusion/NoOp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,37 +42,37 @@ namespace dsl {
struct NoOp {

template <typename DSL, typename... Args>
static inline void bind(const std::shared_ptr<threading::Reaction>& /*reaction*/, Args... /*args*/) {
static void bind(const std::shared_ptr<threading::Reaction>& /*reaction*/, Args... /*args*/) {
// Empty as this is a no-op placeholder
}

template <typename DSL>
static inline std::tuple<> get(const threading::ReactionTask& /*task*/) {
static std::tuple<> get(const threading::ReactionTask& /*task*/) {
return {};
}

template <typename DSL>
static inline bool precondition(const threading::ReactionTask& /*task*/) {
static bool precondition(const threading::ReactionTask& /*task*/) {
return true;
}

template <typename DSL>
static inline int priority(const threading::ReactionTask& /*task*/) {
static int priority(const threading::ReactionTask& /*task*/) {
return word::Priority::NORMAL::value;
}

template <typename DSL>
static inline std::set<util::GroupDescriptor> group(const threading::ReactionTask& /*task*/) {
static std::set<util::GroupDescriptor> group(const threading::ReactionTask& /*task*/) {
return {};
}

template <typename DSL>
static inline util::ThreadPoolDescriptor pool(const threading::ReactionTask& /*task*/) {
static util::ThreadPoolDescriptor pool(const threading::ReactionTask& /*task*/) {
return util::ThreadPoolDescriptor{};
}

template <typename DSL>
static inline void postcondition(const threading::ReactionTask& /*task*/) {
static void postcondition(const threading::ReactionTask& /*task*/) {
// Empty as this is a no-op placeholder
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/dsl/fusion/PoolFusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace dsl {
struct PoolFuser<std::tuple<Word>> {

template <typename DSL>
static inline util::ThreadPoolDescriptor pool(threading::ReactionTask& task) {
static util::ThreadPoolDescriptor pool(threading::ReactionTask& task) {

// Return our pool
return Word::template pool<DSL>(task);
Expand All @@ -89,7 +89,7 @@ namespace dsl {
struct PoolFuser<std::tuple<Word1, Word2, WordN...>> {

template <typename DSL>
static inline util::ThreadPoolDescriptor pool(const threading::ReactionTask& /*task*/) {
static util::ThreadPoolDescriptor pool(const threading::ReactionTask& /*task*/) {
throw std::invalid_argument("Can not be a member of more than one pool");
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/dsl/fusion/PostconditionFusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace dsl {
struct PostconditionFuser<std::tuple<Word>> {

template <typename DSL>
static inline void postcondition(threading::ReactionTask& task) {
static void postcondition(threading::ReactionTask& task) {

// Run our remaining postcondition
Word::template postcondition<DSL>(task);
Expand All @@ -88,7 +88,7 @@ namespace dsl {
struct PostconditionFuser<std::tuple<Word1, Word2, WordN...>> {

template <typename DSL>
static inline void postcondition(threading::ReactionTask& task) {
static void postcondition(threading::ReactionTask& task) {

// Run our postcondition
Word1::template postcondition<DSL>(task);
Expand Down
4 changes: 2 additions & 2 deletions src/dsl/fusion/PreconditionFusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace dsl {
struct PreconditionFuser<std::tuple<Word>> {

template <typename DSL>
static inline bool precondition(threading::ReactionTask& task) {
static bool precondition(threading::ReactionTask& task) {

// Run our remaining precondition
return Word::template precondition<DSL>(task);
Expand All @@ -88,7 +88,7 @@ namespace dsl {
struct PreconditionFuser<std::tuple<Word1, Word2, WordN...>> {

template <typename DSL>
static inline bool precondition(threading::ReactionTask& task) {
static bool precondition(threading::ReactionTask& task) {

// Perform a recursive and operation ending with the first false
return Word1::template precondition<DSL>(task)
Expand Down
4 changes: 2 additions & 2 deletions src/dsl/fusion/PriorityFusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace dsl {
struct PriorityFuser<std::tuple<Word>> {

template <typename DSL>
static inline int priority(threading::ReactionTask& task) {
static int priority(threading::ReactionTask& task) {

// Return our priority
return Word::template priority<DSL>(task);
Expand All @@ -86,7 +86,7 @@ namespace dsl {
struct PriorityFuser<std::tuple<Word1, Word2, WordN...>> {

template <typename DSL>
static inline int priority(threading::ReactionTask& task) {
static int priority(threading::ReactionTask& task) {

// Choose our maximum priority
return std::max(Word1::template priority<DSL>(task),
Expand Down
2 changes: 1 addition & 1 deletion src/dsl/operation/CacheGet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace dsl {
struct CacheGet {

template <typename DSL, typename T = DataType>
static inline std::shared_ptr<const T> get(const threading::ReactionTask& /*task*/) {
static std::shared_ptr<const T> get(const threading::ReactionTask& /*task*/) {

return store::ThreadStore<std::shared_ptr<T>>::value == nullptr
? store::DataStore<DataType>::get()
Expand Down
8 changes: 4 additions & 4 deletions src/dsl/operation/ChronoTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace dsl {
*
* @return true if the task updated the time to run to a new time
*/
inline bool operator()() {
bool operator()() {
return task(time);
}

Expand All @@ -70,7 +70,7 @@ namespace dsl {
*
* @return true if the other task is after this task
*/
inline bool operator<(const ChronoTask& other) const {
bool operator<(const ChronoTask& other) const {
return time < other.time;
}

Expand All @@ -81,7 +81,7 @@ namespace dsl {
*
* @return true if the other task is before this task
*/
inline bool operator>(const ChronoTask& other) const {
bool operator>(const ChronoTask& other) const {
return time > other.time;
}

Expand All @@ -92,7 +92,7 @@ namespace dsl {
*
* @return true if the other task is at the same time as this task
*/
inline bool operator==(const ChronoTask& other) const {
bool operator==(const ChronoTask& other) const {
return time == other.time;
}

Expand Down
2 changes: 1 addition & 1 deletion src/dsl/operation/TypeBind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace dsl {
struct TypeBind {

template <typename DSL>
static inline void bind(const std::shared_ptr<threading::Reaction>& reaction) {
static void bind(const std::shared_ptr<threading::Reaction>& reaction) {

// Set this reaction as no stats emitting
reaction->emit_stats &= EmitStats<DataType>::value;
Expand Down
8 changes: 4 additions & 4 deletions src/dsl/word/Always.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace dsl {
struct Always {

template <typename DSL>
static inline util::ThreadPoolDescriptor pool(const threading::ReactionTask& task) {
static util::ThreadPoolDescriptor pool(const threading::ReactionTask& task) {
static std::map<NUClear::id_t, NUClear::id_t> pool_ids;
static std::mutex mutex;

Expand All @@ -97,7 +97,7 @@ namespace dsl {
}

template <typename DSL>
static inline void bind(const std::shared_ptr<threading::Reaction>& reaction) {
static void bind(const std::shared_ptr<threading::Reaction>& reaction) {

// Create an unbinder for the always reaction
reaction->unbinders.push_back([](threading::Reaction& r) {
Expand All @@ -111,7 +111,7 @@ namespace dsl {
}

template <typename DSL>
static inline void postcondition(threading::ReactionTask& task) {
static void postcondition(threading::ReactionTask& task) {
// Get a task for the always reaction and submit it to the scheduler
PowerPlant::powerplant->submit(task.parent->get_task());
}
Expand All @@ -126,7 +126,7 @@ namespace dsl {
* @return a unique pointer to the idle task which will resubmit the Always task and itself
*/
template <typename DSL>
static inline std::unique_ptr<threading::ReactionTask> make_idle_task(
static std::unique_ptr<threading::ReactionTask> make_idle_task(
const std::shared_ptr<threading::Reaction>& reaction) {

auto idle_task = std::make_unique<threading::ReactionTask>(
Expand Down
2 changes: 1 addition & 1 deletion src/dsl/word/Buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace dsl {
struct Buffer {

template <typename DSL>
static inline bool precondition(const threading::ReactionTask& task) {
static bool precondition(const threading::ReactionTask& task) {
// We only run if there are less than the target number of active tasks
return task.parent->active_tasks.load(std::memory_order_acquire) < (n + 1);
}
Expand Down
5 changes: 2 additions & 3 deletions src/dsl/word/Every.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ namespace dsl {
struct Every<0, period> {

template <typename DSL>
static inline void bind(const std::shared_ptr<threading::Reaction>& reaction,
NUClear::clock::duration jump) {
static void bind(const std::shared_ptr<threading::Reaction>& reaction, NUClear::clock::duration jump) {

reaction->unbinders.push_back([](const threading::Reaction& r) {
r.reactor.emit<emit::Direct>(std::make_unique<operation::Unbind<operation::ChronoTask>>(r.id));
Expand All @@ -113,7 +112,7 @@ namespace dsl {
struct Every {

template <typename DSL>
static inline void bind(const std::shared_ptr<threading::Reaction>& reaction) {
static void bind(const std::shared_ptr<threading::Reaction>& reaction) {
Every<>::bind<DSL>(reaction, period(ticks));
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/dsl/word/Group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace dsl {
static const util::GroupDescriptor group_descriptor;

template <typename DSL>
static inline std::set<util::GroupDescriptor> group(const threading::ReactionTask& /*task*/) {
static std::set<util::GroupDescriptor> group(const threading::ReactionTask& /*task*/) {
return {group_descriptor};
}
};
Expand Down
Loading

0 comments on commit ad1aa13

Please sign in to comment.