Skip to content

Commit

Permalink
More refactorings based on clang-tidy reports
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Feb 7, 2018
1 parent 78d0d88 commit f80c205
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 63 deletions.
16 changes: 6 additions & 10 deletions hpx/lcos/detail/async_implementations.hpp
Expand Up @@ -363,11 +363,9 @@ namespace hpx { namespace detail
return sync_local_invoke<action_type, result_type>::call(
id, std::move(addr), std::forward<Ts>(vs)...);
}
else
{
f = hpx::async(action_invoker<action_type>(),
addr.address_, addr.type_, std::forward<Ts>(vs)...);
}

f = hpx::async(action_invoker<action_type>(),
addr.address_, addr.type_, std::forward<Ts>(vs)...);

return keep_alive(std::move(f), id, std::move(r.second));
}
Expand All @@ -379,11 +377,9 @@ namespace hpx { namespace detail
return sync_local_invoke<action_type, result_type>::call(
id, std::move(addr), std::forward<Ts>(vs)...);
}
else
{
f = hpx::async(action_invoker<action_type>(),
addr.address_, addr.type_, std::forward<Ts>(vs)...);
}

f = hpx::async(action_invoker<action_type>(),
addr.address_, addr.type_, std::forward<Ts>(vs)...);

return keep_alive(std::move(f), id);
}
Expand Down
2 changes: 1 addition & 1 deletion hpx/lcos/latch.hpp
Expand Up @@ -41,7 +41,7 @@ namespace hpx { namespace lcos

/// Extension: Create a client side representation for the existing
/// \a server#latch instance with the given global id \a id.
latch(naming::id_type id)
latch(naming::id_type const& id)
: base_type(id)
{}

Expand Down
17 changes: 8 additions & 9 deletions hpx/lcos/local/futures_factory.hpp
Expand Up @@ -111,15 +111,14 @@ namespace hpx { namespace lcos { namespace local
threads::thread_priority_boost, get_worker_thread_num(),
stacksize, ec);
}
else {
threads::register_thread_nullary(
util::deferred_call(
&base_type::run_impl, std::move(this_)),
util::thread_description(f_, "task_object::apply"),
threads::pending, false, priority, std::size_t(-1),
stacksize, ec);
return threads::invalid_thread_id;
}

threads::register_thread_nullary(
util::deferred_call(
&base_type::run_impl, std::move(this_)),
util::thread_description(f_, "task_object::apply"),
threads::pending, false, priority, std::size_t(-1),
stacksize, ec);
return threads::invalid_thread_id;
}
};

Expand Down
22 changes: 9 additions & 13 deletions hpx/runtime/actions/basic_action.hpp
Expand Up @@ -298,13 +298,11 @@ namespace hpx { namespace actions
typename Derived::thread_function()),
lva, comptype, std::forward<Ts>(vs)...));
}
else
{
return traits::action_decorate_function<Derived>::call(lva,
util::bind(util::one_shot(
typename Derived::thread_function(target)),
lva, comptype, std::forward<Ts>(vs)...));
}

return traits::action_decorate_function<Derived>::call(lva,
util::bind(util::one_shot(
typename Derived::thread_function(target)),
lva, comptype, std::forward<Ts>(vs)...));
}

// This static construct_thread_function allows to construct
Expand All @@ -328,12 +326,10 @@ namespace hpx { namespace actions
thread_function(std::move(cont), lva, invoker(),
lva, comptype, std::forward<Ts>(vs)...));
}
else
{
return traits::action_decorate_function<Derived>::call(lva,
thread_function(target, std::move(cont), lva, invoker(),
lva, comptype, std::forward<Ts>(vs)...));
}

return traits::action_decorate_function<Derived>::call(lva,
thread_function(target, std::move(cont), lva, invoker(),
lva, comptype, std::forward<Ts>(vs)...));
}

// direct execution
Expand Down
4 changes: 2 additions & 2 deletions hpx/runtime/actions/detail/action_factory.hpp
Expand Up @@ -86,8 +86,8 @@ namespace hpx { namespace actions { namespace detail
{
if (has_continuation)
return new transfer_continuation_action<Action>();
else
return new transfer_action<Action>();

return new transfer_action<Action>();
}

template <typename Action>
Expand Down
2 changes: 1 addition & 1 deletion hpx/runtime/parcelset/parcelhandler.hpp
Expand Up @@ -437,7 +437,7 @@ namespace hpx { namespace parcelset
return priority_.find(name)->second;
}

parcelport *find_parcelport(std::string const& type, error_code = throws) const
parcelport *find_parcelport(std::string const& type, error_code& = throws) const
{
int priority = get_priority(type);
if(priority <= 0) return nullptr;
Expand Down
24 changes: 12 additions & 12 deletions hpx/runtime/threads/coroutines/detail/context_windows_fibers.hpp
Expand Up @@ -57,8 +57,8 @@ namespace hpx { namespace threads { namespace coroutines
{
prepare_main_thread()
{
LPVOID result = ConvertThreadToFiber(0);
HPX_ASSERT(0 != result);
LPVOID result = ConvertThreadToFiber(nullptr);
HPX_ASSERT(nullptr != result);
HPX_UNUSED(result);
}

Expand Down Expand Up @@ -95,7 +95,7 @@ namespace hpx { namespace threads { namespace coroutines
return IsThreadAFiber() ? true : false;
#else
fiber_ptr current = GetCurrentFiber();
return current != 0 && current != fiber_magic;
return current != nullptr && current != fiber_magic;
#endif
}

Expand All @@ -113,7 +113,7 @@ namespace hpx { namespace threads { namespace coroutines
* An empty context cannot be restored from,
* but can be saved in.
*/
fibers_context_impl_base() : m_ctx(0) {}
fibers_context_impl_base() : m_ctx(nullptr) {}

/*
* Free function. Saves the current context in @p from
Expand All @@ -133,9 +133,9 @@ namespace hpx { namespace threads { namespace coroutines
{
if (!is_fiber())
{
HPX_ASSERT(from.m_ctx == 0);
from.m_ctx = ConvertThreadToFiber(0);
HPX_ASSERT(from.m_ctx != 0);
HPX_ASSERT(from.m_ctx == nullptr);
from.m_ctx = ConvertThreadToFiber(nullptr);
HPX_ASSERT(from.m_ctx != nullptr);

#if defined(HPX_HAVE_SWAP_CONTEXT_EMULATION)
switch_to_fiber(to.m_ctx);
Expand All @@ -145,9 +145,9 @@ namespace hpx { namespace threads { namespace coroutines
BOOL result = ConvertFiberToThread();
HPX_ASSERT(result);
HPX_UNUSED(result);
from.m_ctx = 0;
from.m_ctx = nullptr;
} else {
bool call_from_main = from.m_ctx == 0;
bool call_from_main = from.m_ctx == nullptr;
if (call_from_main)
from.m_ctx = GetCurrentFiber();
#if defined(HPX_HAVE_SWAP_CONTEXT_EMULATION)
Expand All @@ -156,7 +156,7 @@ namespace hpx { namespace threads { namespace coroutines
SwitchToFiber(to.m_ctx);
#endif
if (call_from_main)
from.m_ctx = 0;
from.m_ctx = nullptr;
}
}

Expand Down Expand Up @@ -206,7 +206,7 @@ namespace hpx { namespace threads { namespace coroutines
),
stacksize_(stack_size == -1 ? default_stack_size : stack_size)
{
if (0 == m_ctx)
if (m_ctx == nullptr)
{
throw boost::system::system_error(
boost::system::error_code(
Expand All @@ -219,7 +219,7 @@ namespace hpx { namespace threads { namespace coroutines

~fibers_context_impl()
{
if (m_ctx)
if (m_ctx != nullptr)
DeleteFiber(m_ctx);
}

Expand Down
6 changes: 3 additions & 3 deletions hpx/runtime/threads/policies/callback_notifier.hpp
Expand Up @@ -26,9 +26,9 @@ namespace hpx { namespace threads { namespace policies
void(std::size_t, std::exception_ptr const&)> on_error_type;

public:
callback_notifier(on_startstop_type start = on_startstop_type(),
on_startstop_type stop = on_startstop_type(),
on_error_type on_err = on_error_type())
callback_notifier(on_startstop_type const& start = on_startstop_type(),
on_startstop_type const& stop = on_startstop_type(),
on_error_type const& on_err = on_error_type())
: on_start_thread_(start), on_stop_thread_(stop), on_error_(on_err)
{}

Expand Down
2 changes: 1 addition & 1 deletion hpx/runtime_impl.hpp
Expand Up @@ -51,7 +51,7 @@ namespace hpx

//
threads::thread_result_type run_helper(
util::function_nonser<runtime::hpx_main_function_type> func,
util::function_nonser<runtime::hpx_main_function_type> const& func,
int& result);

void wait_helper(compat::mutex& mtx, compat::condition_variable& cond,
Expand Down
4 changes: 2 additions & 2 deletions hpx/util/detail/pack_traversal_impl.hpp
Expand Up @@ -52,7 +52,7 @@ namespace util {
explicit HPX_CONSTEXPR spread_box() noexcept
{
}
explicit HPX_CONSTEXPR spread_box(tuple<>) noexcept
explicit HPX_CONSTEXPR spread_box(tuple<> const&) noexcept
{
}

Expand Down Expand Up @@ -282,7 +282,7 @@ namespace util {
{
return std::move(val);
}
inline void voidify_empty_tuple(tuple<>) noexcept
inline void voidify_empty_tuple(tuple<> const&) noexcept
{
}

Expand Down
6 changes: 2 additions & 4 deletions hpx/util/detail/vtable/vtable.hpp
Expand Up @@ -52,9 +52,8 @@ namespace hpx { namespace util { namespace detail
if (sizeof(T) <= function_storage_size)
{
return *reinterpret_cast<T*>(v);
} else {
return **reinterpret_cast<T**>(v);
}
return **reinterpret_cast<T**>(v);
}

template <typename T>
Expand All @@ -63,9 +62,8 @@ namespace hpx { namespace util { namespace detail
if (sizeof(T) <= function_storage_size)
{
return *reinterpret_cast<T const*>(v);
} else {
return **reinterpret_cast<T* const*>(v);
}
return **reinterpret_cast<T* const*>(v);
}

template <typename T>
Expand Down
3 changes: 1 addition & 2 deletions hpx/util/logging/detail/logger_base.hpp
Expand Up @@ -78,8 +78,7 @@ namespace hpx { namespace util { namespace logging {
m_is_cache_turned_off = true;
return true;
}
else
return false;
return false;
}

/** note: this call does not need to be very efficient,
Expand Down
2 changes: 1 addition & 1 deletion hpx/util/logging/format/destination/file.hpp
Expand Up @@ -76,7 +76,7 @@ namespace detail {
}

struct file_info {
file_info(const std::string& name_, file_settings settings_)
file_info(const std::string& name_, file_settings const& settings_)
: name(name_),
// out( new std::basic_ofstream<char_type>
// ( name_.c_str(), open_flags(settings_) )),
Expand Down
2 changes: 1 addition & 1 deletion hpx/util/plugin/plugin_wrapper.hpp
Expand Up @@ -15,7 +15,7 @@ namespace hpx { namespace util { namespace plugin {
{
struct dll_handle_holder
{
dll_handle_holder(dll_handle dll)
dll_handle_holder(dll_handle const& dll)
: m_dll(dll) {}

~dll_handle_holder()
Expand Down
3 changes: 2 additions & 1 deletion src/runtime_impl.cpp
Expand Up @@ -241,7 +241,8 @@ namespace hpx {

threads::thread_result_type
runtime_impl::run_helper(
util::function_nonser<runtime::hpx_main_function_type> func, int& result)
util::function_nonser<runtime::hpx_main_function_type> const& func,
int& result)
{
lbt_ << "(2nd stage) runtime_impl::run_helper: launching pre_main";

Expand Down

0 comments on commit f80c205

Please sign in to comment.