2
0
mirror of https://github.com/boostorg/context.git synced 2026-01-30 07:42:46 +00:00

fcontext uses 'void*' for data transfer

This commit is contained in:
Oliver Kowalke
2015-11-28 22:58:36 +01:00
parent c70440f0ff
commit 4d68f47767
12 changed files with 134 additions and 246 deletions

View File

@@ -24,12 +24,12 @@ ctx::fcontext_t fcm = 0;
ctx::fcontext_t fc = 0;
boost::exception_ptr except;
void f( intptr_t arg)
{
try
{ throw std::runtime_error( ( char *) arg); }
catch ( std::runtime_error const& e)
{ except = boost::current_exception(); }
void f( void * arg) {
try {
throw std::runtime_error( ( char *) arg);
} catch ( std::runtime_error const& e) {
except = boost::current_exception();
}
ctx::jump_fcontext( & fc, fcm, arg);
}
@@ -42,13 +42,14 @@ int main( int argc, char * argv[])
std::cout << "main: call start_fcontext( & fcm, fc, 0)" << std::endl;
const char * what = "hello world";
ctx::jump_fcontext( & fcm, fc, ( intptr_t) what);
try
{ if ( except) boost::rethrow_exception( except); }
catch ( std::exception const& ex)
{ std::cerr << "exception: " << ex.what() << std::endl; }
ctx::jump_fcontext( & fcm, fc, ( void *) what);
try {
if ( except) {
boost::rethrow_exception( except);
}
} catch ( std::exception const& ex) {
std::cerr << "exception: " << ex.what() << std::endl;
}
std::cout << "main: done" << std::endl;
return EXIT_SUCCESS;
}