...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
A wrapper more aligned with modern C++ practice would use an exception, rather
than an errorcode
, to communicate
failure to its caller. This is straightforward to code in terms of write_ec()
:
void write( AsyncAPI & api, std::string const& data) { AsyncAPI::errorcode ec = write_ec( api, data); if ( ec) { throw make_exception("write", ec); } }
The point is that since each fiber has its own stack, you need not repeat messy boilerplate: normal encapsulation works.