1 /* Copyright (c) 2015-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_KERNEL_CONTEXT_BOOST_CONTEXT_HPP
7 #define SIMGRID_KERNEL_CONTEXT_BOOST_CONTEXT_HPP
9 #include <boost/version.hpp>
10 #if BOOST_VERSION < 106100
11 #include <boost/context/fcontext.hpp>
13 #include <boost/context/detail/fcontext.hpp>
21 #include "src/kernel/context/ContextSwapped.hpp"
22 #include "src/xbt/parmap.hpp"
24 namespace simgrid::kernel::context {
26 /** @brief Userspace context switching implementation based on Boost.Context */
27 class BoostContext : public SwappedContext {
29 BoostContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
32 #if BOOST_VERSION < 106100
33 boost::context::fcontext_t fc_{};
34 using arg_type = intptr_t;
36 boost::context::detail::fcontext_t fc_{};
37 using arg_type = boost::context::detail::transfer_t;
40 XBT_ATTRIB_NORETURN static void wrapper(arg_type arg);
42 void swap_into_for_real(SwappedContext* to) override;
45 class BoostContextFactory : public SwappedContextFactory {
47 BoostContext* create_context(std::function<void()>&& code, actor::ActorImpl* actor) override;
49 } // namespace simgrid::kernel::context