-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first step on custom coro frame hacking.
- Loading branch information
1 parent
820f9c3
commit f61014d
Showing
5 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2023 Klemens D. Morgenstern | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
#ifndef BOOST_COBALT_FIBER_HPP | ||
#define BOOST_COBALT_FIBER_HPP | ||
|
||
#include <boost/context/fiber.hpp> | ||
|
||
// this is all UB according to the standard. BUT it shouldn't be! | ||
|
||
namespace boost::cobalt::experimental | ||
{ | ||
|
||
namespace detail | ||
{ | ||
|
||
struct fiber_promise | ||
{ | ||
|
||
}; | ||
|
||
struct fiber_frame | ||
{ | ||
void (*resume_) (fiber_frame *) = +[](fiber_frame * ff) { ff->resume();}; | ||
void (*destroy_)(fiber_frame *) = +[](fiber_frame * ff) { ff->destroy();}; | ||
|
||
fiber_promise promise; | ||
|
||
void resume() {} | ||
void destroy() {} | ||
}; | ||
|
||
} | ||
|
||
} | ||
|
||
#endif //BOOST_COBALT_FIBER_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2023 Klemens D. Morgenstern | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include <boost/cobalt/experimental/fiber.hpp> | ||
|
||
#include "../test.hpp" | ||
|
||
BOOST_AUTO_TEST_SUITE(fiber); | ||
|
||
BOOST_AUTO_TEST_CASE(basics) | ||
{ | ||
boost::cobalt::experimental::detail::fiber_frame ff; | ||
|
||
using pro = boost::cobalt::experimental::detail::fiber_promise; | ||
auto hh = std::coroutine_handle<pro>::from_address(&ff); | ||
BOOST_CHECK(!hh.done()); | ||
ff.resume_ = nullptr; | ||
BOOST_CHECK(hh.done()); | ||
|
||
BOOST_CHECK(&ff.promise == &hh.promise()); | ||
BOOST_CHECK(std::coroutine_handle<pro>::from_promise(ff.promise).address() == &ff); | ||
} | ||
|
||
|
||
BOOST_AUTO_TEST_SUITE_END(); |