示例#1
0
void test_case_5()
{
    value1 = 1;
    BOOST_CHECK_EQUAL( 1, value1);
    BOOST_CHECK_EQUAL( std::string(""), value3);
    gctx = boost::contexts::context(
        fn3, "abc",
        boost::contexts::default_stacksize(),
        boost::contexts::stack_unwind, boost::contexts::return_to_caller);
    BOOST_CHECK( ! gctx.is_started() );
    BOOST_CHECK( ! gctx.is_complete() );
    intptr_t vp = gctx.start();
    BOOST_CHECK( gctx.is_started() );
    BOOST_CHECK( ! gctx.is_resumed() );
    BOOST_CHECK( ! gctx.is_complete() );
    BOOST_CHECK_EQUAL( vp, value1);
    BOOST_CHECK_EQUAL( 1, value1);
    int x = 7;
    vp = 0;
    vp = gctx.resume( x);
    BOOST_CHECK_EQUAL( 7, value1);
    BOOST_CHECK( ! vp);
    BOOST_CHECK( ! gctx.is_complete() );
    BOOST_CHECK( gctx.is_resumed() );
    BOOST_CHECK_EQUAL( std::string(""), value3);
    gctx.unwind_stack();
    BOOST_CHECK( gctx.is_complete() );
    BOOST_CHECK_EQUAL( std::string("abc"), value3);
}
示例#2
0
int main( int argc, char * argv[])
{
    ctx = boost::contexts::context(
            fn,
            boost::contexts::default_stacksize(),
			boost::contexts::no_stack_unwind, boost::contexts::return_to_caller);
    ctx.start();
    for ( int i = 0; i < 4; ++i)
    {
        ctx.resume();
    }

    std::cout << "ctx is complete: " << std::boolalpha << ctx.is_complete() << "\n";
    std::cout << "call ctx.unwind_stack()" << std::endl;
    ctx.unwind_stack();
    std::cout << "ctx is complete: " << std::boolalpha << ctx.is_complete() << "\n";

    std::cout << "Done" << std::endl;

    return EXIT_SUCCESS;
}