Skip to content

Overload all post member functions for V1 and V2 API#114

Merged
accelerated merged 1 commit intobloomberg:masterfrom
accelerated:post_overload
Aug 30, 2019
Merged

Overload all post member functions for V1 and V2 API#114
accelerated merged 1 commit intobloomberg:masterfrom
accelerated:post_overload

Conversation

@accelerated
Copy link
Copy Markdown
Contributor

Signed-off-by: Alexander Damian adamian@bloomberg.net

Describe your changes

  • Using SFINAE and automatic return value type deduction, overload all the post member functions (post, postAsyncIo, postFirst, then, onError, finally) to accept both V1 and V2 API. The application is not longer required to explicitly call post2 functions in order to run V2 API functions and can use a single overload instead.

Example:

//V1 API
auto func1 = [](CoroContextPtr<std::string> ctx)->int { return ctx->set("HelloWorld!"); }
//V2 API
auto func2 = [](VoidContextPtr)->std::string { return "HelloWorld!"; }

Dispatcher d;
d.post(func1); //ok
d.post(func2); //ok (use overload)
d.post2(func2); //still ok (kept for backward compatibility)

NOTE: forEach, forEachBatch, mapReduce, mapReduceBatch as well as the Sequencer class, still accept only V2 API.

Testing performed
Ran unit tests using overloaded dispatch functions.

Signed-off-by: Alexander Damian <adamian@bloomberg.net>
@accelerated accelerated merged commit 2e86585 into bloomberg:master Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant