1 /* Copyright (c) 2015-2019. 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_SIMIX_BOOST_CONTEXT_HPP
7 #define SIMGRID_SIMIX_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 <simgrid/simix.hpp>
22 #include <xbt/parmap.hpp>
24 #include "src/internal_config.h"
25 #include "src/kernel/context/Context.hpp"
26 #include "src/kernel/context/ContextSwapped.hpp"
32 /** @brief Userspace context switching implementation based on Boost.Context */
33 class BoostContext : public SwappedContext {
35 BoostContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
36 ~BoostContext() override;
38 void swap_into(SwappedContext* to) override;
41 #if BOOST_VERSION < 105600
42 boost::context::fcontext_t* fc_ = nullptr;
43 typedef intptr_t arg_type;
44 #elif BOOST_VERSION < 106100
45 boost::context::fcontext_t fc_;
46 typedef intptr_t arg_type;
48 boost::context::detail::fcontext_t fc_;
49 typedef boost::context::detail::transfer_t arg_type;
52 static void wrapper(arg_type arg);
55 class BoostContextFactory : public SwappedContextFactory {
57 BoostContext* create_context(std::function<void()>&& code, actor::ActorImpl* actor) override;
59 } // namespace context
61 } // namespace simgrid