From 645377e1910a4dd1124c183777120351de02ce00 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Wed, 2 Mar 2016 20:36:05 -0700 Subject: [PATCH] Remove memory_order_relaxed usage --- .../chaiscript/dispatchkit/dispatchkit.hpp | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index 23dc7ee8..b2848ae4 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -635,7 +635,7 @@ namespace chaiscript loc_mask = 0x0000FFFF }; - uint_fast32_t loc = t_loc.load(std::memory_order_relaxed); + uint_fast32_t loc = t_loc; if (loc == 0) { @@ -647,17 +647,16 @@ namespace chaiscript for (auto s = stack_elem->begin(); s != stack_elem->end(); ++s ) { if (s->first == name) { - t_loc.store( static_cast(std::distance(stack.rbegin(), stack_elem) << 16) - | static_cast(std::distance(stack_elem->begin(), s)) - | static_cast(Loc::located) - | static_cast(Loc::is_local), - std::memory_order_relaxed); + t_loc = static_cast(std::distance(stack.rbegin(), stack_elem) << 16) + | static_cast(std::distance(stack_elem->begin(), s)) + | static_cast(Loc::located) + | static_cast(Loc::is_local); return s->second; } } } - t_loc.store( static_cast(Loc::located), std::memory_order_relaxed); + t_loc = static_cast(Loc::located); } else if (loc & static_cast(Loc::is_local)) { auto &stack = get_stack_data(); @@ -675,7 +674,7 @@ namespace chaiscript // no? is it a function object? auto obj = get_function_object_int(name, loc); - if (obj.first != loc) t_loc.store(uint_fast32_t(obj.first), std::memory_order_relaxed); + if (obj.first != loc) t_loc = uint_fast32_t(obj.first); return obj.second; @@ -738,9 +737,9 @@ namespace chaiscript std::shared_ptr> get_method_missing_functions() const { - uint_fast32_t method_missing_loc = m_method_missing_loc.load(std::memory_order_relaxed); + uint_fast32_t method_missing_loc = m_method_missing_loc; auto method_missing_funs = get_function("method_missing", method_missing_loc); - if (method_missing_funs.first != method_missing_loc) m_method_missing_loc.store(uint_fast32_t(method_missing_funs.first), std::memory_order_relaxed); + if (method_missing_funs.first != method_missing_loc) m_method_missing_loc = uint_fast32_t(method_missing_funs.first); return std::move(method_missing_funs.second); } @@ -938,9 +937,9 @@ namespace chaiscript Boxed_Value call_member(const std::string &t_name, std::atomic_uint_fast32_t &t_loc, const std::vector ¶ms, bool t_has_params, const Type_Conversions_State &t_conversions) { - uint_fast32_t loc = t_loc.load(std::memory_order_relaxed); + uint_fast32_t loc = t_loc; const auto funs = get_function(t_name, loc); - if (funs.first != loc) t_loc.store(uint_fast32_t(funs.first), std::memory_order_relaxed); + if (funs.first != loc) t_loc = uint_fast32_t(funs.first); const auto do_attribute_call = [this](int l_num_params, const std::vector &l_params, const std::vector &l_funs, const Type_Conversions_State &l_conversions)->Boxed_Value @@ -1051,9 +1050,9 @@ namespace chaiscript Boxed_Value call_function(const std::string &t_name, std::atomic_uint_fast32_t &t_loc, const std::vector ¶ms, const Type_Conversions_State &t_conversions) const { - uint_fast32_t loc = t_loc.load(std::memory_order_relaxed); + uint_fast32_t loc = t_loc; const auto funs = get_function(t_name, loc); - if (funs.first != loc) t_loc.store(uint_fast32_t(funs.first), std::memory_order_relaxed); + if (funs.first != loc) t_loc = uint_fast32_t(funs.first); return dispatch::dispatch(*funs.second, params, t_conversions); }