Skip to content

Commit

Permalink
Style cleanup. Fixing deprecated function
Browse files Browse the repository at this point in the history
  • Loading branch information
mdemoret-nv committed Oct 22, 2024
1 parent a03cd8f commit 11b2bbf
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions cpp/mrc/include/mrc/core/fiber_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ class FiberPool
[[nodiscard]] virtual std::size_t thread_count() const = 0;

template <class F, class... ArgsT>
auto enqueue(std::uint32_t index, F&& f, ArgsT&&... args) -> Future<typename std::result_of<F(ArgsT...)>::type>
auto enqueue(std::uint32_t index, F&& f, ArgsT&&... args) -> Future<typename std::invoke_result_t<F, ArgsT...>>
{
return task_queue(index).enqueue(f, std::forward<ArgsT>(args)...);
}

template <class MetaDataT, class F, class... ArgsT>
auto enqueue(std::uint32_t index, MetaDataT&& md, F&& f, ArgsT&&... args)
-> Future<typename std::result_of<F(ArgsT...)>::type>
-> Future<typename std::invoke_result_t<F, ArgsT...>>
{
return task_queue(index).enqueue(std::forward<MetaDataT>(md), std::forward<F>(f), std::forward<ArgsT>(args)...);
}
Expand Down
8 changes: 4 additions & 4 deletions cpp/mrc/include/mrc/core/task_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,31 @@ class FiberTaskQueue
virtual ~FiberTaskQueue() = default;

template <class F, class... ArgsT>
auto enqueue(F&& f, ArgsT&&... args) -> Future<typename std::result_of<F(ArgsT...)>::type>
auto enqueue(F&& f, ArgsT&&... args) -> Future<typename std::invoke_result_t<F, ArgsT...>>
{
FiberMetaData meta_data;
return enqueue(meta_data, std::forward<F>(f), std::forward<ArgsT>(args)...);
}

template <class F, class... ArgsT>
auto enqueue(const FiberMetaData& meta_data, F&& f, ArgsT&&... args)
-> Future<typename std::result_of<F(ArgsT...)>::type>
-> Future<typename std::invoke_result_t<F, ArgsT...>>
{
FiberMetaData copy = meta_data;
return enqueue(std::move(copy), std::forward<F>(f), std::forward<ArgsT>(args)...);
}

template <class F, class... ArgsT>
auto enqueue(FiberMetaData&& meta_data, F&& f, ArgsT&&... args)
-> Future<typename std::result_of<F(ArgsT...)>::type>
-> Future<typename std::invoke_result_t<F, ArgsT...>>
{
if (task_queue().is_closed())
{
throw std::runtime_error("enqueue on stopped ws fiber pool");
}

using namespace boost::fibers;
using return_type_t = typename std::result_of<F(ArgsT...)>::type;
using return_type_t = typename std::invoke_result_t<F, ArgsT...>;

packaged_task<return_type_t()> task(std::bind(std::forward<F>(f), std::forward<ArgsT>(args)...));
future<return_type_t> future = task.get_future();
Expand Down
1 change: 1 addition & 0 deletions cpp/mrc/src/internal/segment/builder_definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include <glog/logging.h>

#include <algorithm>
#include <exception>
#include <memory>
#include <numeric>
Expand Down
10 changes: 5 additions & 5 deletions cpp/mrc/src/internal/system/fiber_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class FiberManager final

template <class F>
[[nodiscard]] auto enqueue_fiber(std::uint32_t queue_idx, const F& to_enqueue) const
-> Future<typename std::result_of<F(std::uint32_t)>::type>
-> Future<typename std::invoke_result_t<F, std::uint32_t>>
{
using return_vec_t = Future<typename std::result_of<F(std::uint32_t)>::type>;
using return_vec_t = Future<typename std::invoke_result_t<F, std::uint32_t>>;
return_vec_t future;

auto found = m_queues.find(queue_idx);
Expand All @@ -73,16 +73,16 @@ class FiberManager final
// Runs a function on each thread in this manager. Each function will receive the thread index as the only argument
template <class F>
[[nodiscard]] auto enqueue_fiber_on_all(const F& to_enqueue) const
-> std::vector<Future<typename std::result_of<F(std::uint32_t)>::type>>
-> std::vector<Future<typename std::invoke_result_t<F, std::uint32_t>>>
{
return enqueue_fiber_on_cpuset(m_cpu_set, std::move(to_enqueue));
}

template <class F>
[[nodiscard]] auto enqueue_fiber_on_cpuset(const CpuSet& cpu_set, const F& to_enqueue) const
-> std::vector<Future<typename std::result_of<F(std::uint32_t)>::type>>
-> std::vector<Future<typename std::invoke_result_t<F, std::uint32_t>>>
{
using return_vec_t = std::vector<Future<typename std::result_of<F(std::uint32_t)>::type>>;
using return_vec_t = std::vector<Future<typename std::invoke_result_t<F, std::uint32_t>>>;
return_vec_t futures;

CHECK(m_cpu_set.contains(cpu_set));
Expand Down
4 changes: 2 additions & 2 deletions cpp/mrc/src/internal/system/thread_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class ThreadPool final
~ThreadPool();

template <class F, class... ArgsT>
auto enqueue(F&& f, ArgsT&&... args) -> boost::fibers::future<typename std::result_of<F(ArgsT...)>::type>
auto enqueue(F&& f, ArgsT&&... args) -> boost::fibers::future<typename std::invoke_result_t<F, ArgsT...>>
{
using return_type_t = typename std::result_of<F(ArgsT...)>::type;
using return_type_t = typename std::invoke_result_t<F, ArgsT...>;

boost::fibers::packaged_task<return_type_t()> task(std::bind(std::forward<F>(f), std::forward<ArgsT>(args)...));
boost::fibers::future<return_type_t> future = task.get_future();
Expand Down
1 change: 1 addition & 0 deletions cpp/mrc/src/public/modules/segment_modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <glog/logging.h>

#include <algorithm>
#include <sstream>
#include <stdexcept>
#include <utility>
Expand Down
1 change: 1 addition & 0 deletions cpp/mrc/tests/modules/dynamic_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <nlohmann/json.hpp>
#include <rxcpp/rx.hpp>

#include <algorithm>
#include <memory>
#include <string>
#include <utility>
Expand Down
1 change: 0 additions & 1 deletion cpp/mrc/tests/test_edges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <gtest/gtest.h>
#include <rxcpp/rx.hpp> // for observable_member

#include <chrono>
#include <memory>
#include <stdexcept>
#include <utility>
Expand Down

0 comments on commit 11b2bbf

Please sign in to comment.