Allow use of boost::future as zk::future #112
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey,
So we would like to use
boost::future
also therefore I made this implementation. This might not be ideal solution, but it solves my problem.Most of the 'not ideal solution' comes from the fact, that calling
boost::promise::set_exception()
withboost::current_exception()
requires that exception would be either thrown withboost::throw_exception()
or wrapped inboost::enable_current_exception(...)
(I tested on gcc 7 and without wrapping, exception rethrown was of wrong type). To work around this I addedzk::throw_exception()
wrapper which either throws directly forstd::future
case or does necessary wrapping when usingboost::future
.Another problem was that
boost::enable_current_exception()
, requires derived exception types. Therefore I removedfinal
declarations from error types.Also I introduced
zk::exception_ptr
,zk::current_exception()
andzk::async()
to map either tostd
variants orboost
ones for compatability.This most likely solves #108 and #107