#pragma once #include "common/QLogging.hpp" #include #include #include namespace chatterino { class TwitchAccount; struct ActionUser; // Create timer using given ioService template void runAfter(boost::asio::io_service &ioService, Duration duration, Callback cb) { auto timer = std::make_shared(ioService); timer->expires_from_now(duration); timer->async_wait([timer, cb](const boost::system::error_code &ec) { if (ec) { qCDebug(chatterinoPubSub) << "Error in runAfter:" << ec.message().c_str(); return; } cb(timer); }); } // Use provided timer template void runAfter(std::shared_ptr timer, Duration duration, Callback cb) { timer->expires_from_now(duration); timer->async_wait([timer, cb](const boost::system::error_code &ec) { if (ec) { qCDebug(chatterinoPubSub) << "Error in runAfter:" << ec.message().c_str(); return; } cb(timer); }); } } // namespace chatterino