Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <boost/signals2.hpp>
- #include <thread>
- #include <memory>
- #include <chrono>
- struct Signaller
- {
- boost::signals2::signal<void(int)> onAdcReady;
- };
- int main()
- {
- auto pSignaller = std::make_unique<Signaller>();
- pSignaller->onAdcReady.connect(
- [](int _newValue)
- {
- using namespace std::chrono_literals;
- std::cout<<_newValue<<std::endl;
- }
- );
- std::thread adcReader(
- [ pSigObject = std::move(pSignaller) ]
- {
- using namespace std::chrono_literals;
- std::this_thread::sleep_for(1s);
- pSigObject->onAdcReady(42);
- }
- );
- adcReader.detach();
- while(true)
- {
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement