Skip to content

Commit

Permalink
inline msvc workarounds.
Browse files Browse the repository at this point in the history
  • Loading branch information
klemens-morgenstern committed Oct 23, 2023
1 parent 4ffee96 commit abfa3d0
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 13 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,10 @@ else()
if (NOT BOOST_COBALT_BUILD_INLINE)
find_package(Threads REQUIRED)
# Boost 1.82 is the first with a Boost.ASIO with necessary support
find_package(Boost 1.82 REQUIRED COMPONENTS system OPTIONAL_COMPONENTS json context url)
find_package(Boost REQUIRED COMPONENTS system OPTIONAL_COMPONENTS json context url)
if (BOOST_COBALT_USE_BOOST_CONTAINER)
find_package(Boost REQUIRED container)
endif()
if (BOOST_COBALT_BUILD_TESTS)
find_package(Boost REQUIRED unit_test_framework)
endif()
include_directories(include)
endif()

Expand Down
6 changes: 6 additions & 0 deletions include/boost/cobalt/detail/gather.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ struct gather_variadic_impl
template<typename T>
using result_part = system::result<co_await_result_t<T>, std::exception_ptr>;

#if _MSC_VER
BOOST_NOINLINE
#endif
std::tuple<result_part<Args> ...> await_resume()
{
return mp11::tuple_transform(
Expand Down Expand Up @@ -379,6 +382,9 @@ struct gather_ranged_impl
return true;
}

#if _MSC_VER
BOOST_NOINLINE
#endif
auto await_resume()
{
#if !defined(BOOST_COBALT_NO_PMR)
Expand Down
6 changes: 6 additions & 0 deletions include/boost/cobalt/detail/join.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ struct join_variadic_impl
return true;
}

#if _MSC_VER
BOOST_NOINLINE
#endif
auto await_resume()
{
if (error)
Expand Down Expand Up @@ -510,6 +513,9 @@ struct join_ranged_impl
}
}

#if _MSC_VER
BOOST_NOINLINE
#endif
auto await_resume()
{
if (error)
Expand Down
6 changes: 6 additions & 0 deletions include/boost/cobalt/detail/race.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ struct race_variadic_impl
return true;
}

#if _MSC_VER
BOOST_NOINLINE
#endif
auto await_resume()
{
if (error)
Expand Down Expand Up @@ -644,6 +647,9 @@ struct race_ranged_impl
return true;
}

#if _MSC_VER
BOOST_NOINLINE
#endif
auto await_resume()
{
if (error)
Expand Down
7 changes: 0 additions & 7 deletions include/boost/cobalt/thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ void thread::cancel(asio::cancellation_type type)
});
}

inline void thread::join() {thread_.join();}
inline bool thread::joinable() const {return thread_.joinable();}
inline void thread::detach()
{
thread_.detach();
state_ = nullptr;
}

inline
auto thread::operator co_await() &-> detail::thread_awaitable
Expand Down
16 changes: 14 additions & 2 deletions src/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
#include <boost/asio/bind_executor.hpp>


namespace boost::cobalt::detail
namespace boost::cobalt
{

namespace detail
{

thread_promise::thread_promise()
Expand Down Expand Up @@ -78,7 +81,16 @@ boost::cobalt::thread detail::thread_promise::get_return_object()
};

return res;
}
}


}

void thread::join() {thread_.join();}
bool thread::joinable() const {return thread_.joinable();}
void thread::detach()
{
thread_.detach();
state_ = nullptr;
}
}

0 comments on commit abfa3d0

Please sign in to comment.