File indexing completed on 2024-06-23 05:27:09

0001 /*
0002     SPDX-FileCopyrightText: 2018 Ivan Čukić <ivan.cukic(at)kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef VOY_TRASNPORT_ASIO_SERVICE_H
0008 #define VOY_TRASNPORT_ASIO_SERVICE_H
0009 
0010 // Boost
0011 #include <boost/asio/io_service.hpp>
0012 
0013 namespace voy::engine::asio {
0014 
0015 class service {
0016 public:
0017     static service& instance();
0018 
0019     void run();
0020 
0021     template <typename F>
0022     inline void invoke_later(F&& f)
0023     {
0024         m_asio_service.post(std::forward<F>(f));
0025     }
0026 
0027     inline operator boost::asio::io_service& ()
0028     {
0029         return m_asio_service;
0030     }
0031 
0032 private:
0033     boost::asio::io_service m_asio_service;
0034 };
0035 
0036 } // namespace voy::engine::asio
0037 
0038 #endif // include guard
0039