Created
June 10, 2019 21:13
-
-
Save Ge0/200c5a04df3fd23e11efe22693b5ee02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <boost/asio.hpp> | |
class Contextable { | |
public: | |
Contextable(boost::asio::io_context& ctx) : m_ioContext(ctx) {} | |
protected: | |
boost::asio::io_context& m_ioContext; | |
}; | |
class Consumer : public Contextable{ | |
public: | |
Consumer(boost::asio::io_context& ctx) : Contextable(ctx) {} | |
void completion(std::string str) { | |
std::cout << "Received " << str << std::endl; | |
} | |
}; | |
int main() { | |
boost::asio::io_context ctx; | |
Consumer c(ctx); | |
ctx.post([&]() { c.completion("foo"); }); | |
ctx.run(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment