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
Describe your changes
post
member functions (post, postAsyncIo, postFirst, then, onError, finally
) to accept both V1 and V2 API. The application is not longer required to explicitly callpost2
functions in order to run V2 API functions and can use a single overload instead.Example:
NOTE:
forEach, forEachBatch, mapReduce, mapReduceBatch
as well as theSequencer
class, still accept only V2 API.Testing performed Ran unit tests using overloaded dispatch functions.