Boost 1.57 Boost.Context fcontext_t resource management

598 views Asked by At

Some context

In Boost 1.57 f_context & make_fcontext looks like this

// fcontext.hpp:
typedef void* fcontext_t;
fcontext_t BOOST_CONTEXT_CALLDECL make_fcontext( void * sp, std::size_t size, void (* fn)( intptr_t) );

How should I manage the resource returned by make_fcontext()?

I have read the docs, asked on IRC and looked at the examples, but could not find anything. Is there a need to release/delete/close this resource?

1

There are 1 answers

0
Tanner Sansbury On BEST ANSWER

For users, fcontext_t is a handle to identify context, and specify which context to jump to with jump_fcontext(). The object pointed to by the opaque pointer returned from make_fcontext(stack, context_function) will be managed by the provided stack. The documentation states:

Creates an fcontext_t on top of the stack [...]

One can also look into the Boost.Coroutine's implementation to see its usage of fcontext_t.