void jump_to void resume ()
void jump_to()
+ void resume()
diff --git a/example/execution_context/jump.cpp b/example/execution_context/jump.cpp index 01baa87..1a48ca4 100644 --- a/example/execution_context/jump.cpp +++ b/example/execution_context/jump.cpp @@ -16,16 +16,16 @@ boost::context::execution_context * ctx = nullptr; void f1( int i) { std::cout << "f1: entered" << std::endl; std::cout << "i == " << i << std::endl; - ctx2->jump_to(); + ctx2->resume(); std::cout << "f1: re-entered" << std::endl; - ctx2->jump_to(); + ctx2->resume(); } void f2() { std::cout << "f2: entered" << std::endl; - ctx1->jump_to(); + ctx1->resume(); std::cout << "f2: re-entered" << std::endl; - ctx->jump_to(); + ctx->resume(); } int main() { @@ -36,7 +36,7 @@ int main() { boost::context::execution_context ctx_( boost::context::execution_context::current() ); ctx = & ctx_; - ctx1->jump_to(); + ctx1->resume(); std::cout << "main: done" << std::endl; diff --git a/example/execution_context/parser.cpp b/example/execution_context/parser.cpp index 2c00311..da16fee 100644 --- a/example/execution_context/parser.cpp +++ b/example/execution_context/parser.cpp @@ -103,20 +103,20 @@ int main() { [&main_ctx,&c](char ch){ c=ch; // resume main execution context - main_ctx.jump_to(); + main_ctx.resume(); }); // start recursive parsing p.run(); done=true; - main_ctx.jump_to(); + main_ctx.resume(); }); // user-code pulls parsed data from parser // invert control flow - parser_ctx.jump_to(); + parser_ctx.resume(); do { printf("Parsed: %c\n",c); - parser_ctx.jump_to(); + parser_ctx.resume(); } while( ! done); std::cout << "main: done" << std::endl; diff --git a/example/execution_context/segmented.cpp b/example/execution_context/segmented.cpp index f076f48..6f5e457 100644 --- a/example/execution_context/segmented.cpp +++ b/example/execution_context/segmented.cpp @@ -57,10 +57,10 @@ int main() { #endif [& main_ctx, count](){ bar( count); - main_ctx.jump_to(); + main_ctx.resume(); }); - bar_ctx.jump_to(); + bar_ctx.resume(); std::cout << "main: done" << std::endl; diff --git a/include/boost/context/execution_context.hpp b/include/boost/context/execution_context.hpp index 751c78f..4d809b0 100644 --- a/include/boost/context/execution_context.hpp +++ b/include/boost/context/execution_context.hpp @@ -275,8 +275,7 @@ public: std::index_sequence_for< Args ... >() ) ) { } - void jump_to( bool preserve_fpu = false) noexcept { - BOOST_ASSERT( * this); + void resume( bool preserve_fpu = false) noexcept { fcontext * old_ctx( current_ctx_.get() ); fcontext * new_ctx( ptr_.get() ); current_ctx_ = ptr_; diff --git a/performance/fcontext/performance_fcontext.cpp b/performance/fcontext/performance_fcontext.cpp index f9f227c..3e370c1 100644 --- a/performance/fcontext/performance_fcontext.cpp +++ b/performance/fcontext/performance_fcontext.cpp @@ -40,7 +40,7 @@ static void foo( intptr_t) { #if __cplusplus >= 201103L static void bar() { while ( true) { - mctx->jump_to(); + mctx->resume(); } } #endif @@ -68,11 +68,11 @@ duration_type measure_time_ec() { // cache warum-up boost::context::fixedsize_stack alloc; boost::context::execution_context ectx( alloc, bar); - ectx.jump_to(); + ectx.resume(); time_point_type start( clock_type::now() ); for ( std::size_t i = 0; i < jobs; ++i) { - ectx.jump_to(); + ectx.resume(); } duration_type total = clock_type::now() - start; total -= overhead_clock(); // overhead of measurement @@ -107,11 +107,11 @@ cycle_type measure_cycles_ec() { // cache warum-up boost::context::fixedsize_stack alloc; boost::context::execution_context ectx( alloc, bar); - ectx.jump_to(); + ectx.resume(); cycle_type start( cycles() ); for ( std::size_t i = 0; i < jobs; ++i) { - ectx.jump_to(); + ectx.resume(); } cycle_type total = cycles() - start; total -= overhead_cycle(); // overhead of measurement diff --git a/test/test_context.cpp b/test/test_context.cpp index 7098729..85797b2 100644 --- a/test/test_context.cpp +++ b/test/test_context.cpp @@ -227,12 +227,12 @@ ctx::execution_context * mctx = nullptr; void f11() { value1 = 3; - mctx->jump_to(); + mctx->resume(); } void f12( int i) { value1 = i; - mctx->jump_to(); + mctx->resume(); } void test_ectx() { @@ -241,7 +241,7 @@ void test_ectx() { value1 = 0; ctx::fixedsize_stack alloc; ctx::execution_context ectx( alloc, f11); - ectx.jump_to(); + ectx.resume(); BOOST_CHECK_EQUAL( 3, value1); } @@ -251,7 +251,7 @@ void test_variadric() { value1 = 0; ctx::fixedsize_stack alloc; ctx::execution_context ectx( alloc, f12, 5); - ectx.jump_to(); + ectx.resume(); BOOST_CHECK_EQUAL( 5, value1); } @@ -264,7 +264,7 @@ void test_prealloc() { void * sp = static_cast< char * >( sctx.sp) - 10; std::size_t size = sctx.size - 10; ctx::execution_context ectx( ctx::preallocated( sp, size, sctx), alloc, f12, 7); - ectx.jump_to(); + ectx.resume(); BOOST_CHECK_EQUAL( 7, value1); } #endif