自实现流式logger版本

singleton.h#pragma once #include <iostream> namespace sky { template <typename T> class singleton { public: singleton(const singleton&) = delete; singleton& operator=(const singleton&) = delete; protected: singleton() noexcept = default; virtual ~singl...

简单实现对象池

#pragma once #include <atomic> #include <memory> #include "concurrentqueue/concurrentqueue.h" #include "logger.h" namespace flower { template <typename T> class object_pool { using object_ptr = std::shared_ptr<T>; public: object_pool() = def...

Asio 定时器封装使用

timer_event.h#pragma once #include <atomic> #include <functional> #include <memory> #include "array_list.h" #include "asio/steady_timer.hpp" #include "asio/dispatch.hpp" namespace flower { constexpr uint16_t timer_max_count = std::numeric_limits&...

Sol2库 封装使用

lua_bind.h#pragma once #include <string> #include <string_view> #include "asio/detail/noncopyable.hpp" #include "io_context_pool.h" #include "logger.h" #include "sol/sol.hpp" namespace flower { class lua_bind final : public asio::detail::nonc...

使用fmt库实现一个logger

logger.h#pragma once #include <atomic> #include <chrono> #include <fstream> #include <mutex> #include <sstream> #include <string> #include <string_view> #include "fmt/chrono.h" #include "fmt/format.h" #include "singleton.h"...

Boost库MySQL 封装使用

Document: https://anarthal.github.io/mysql/index.htmlGitHub: https://github.com/anarthal/mysql db_query.h#pragma once #include <cstdint> #include <memory> #include <string> #include <vector> #include "boost/mysql.hpp" namespace flower { class db_query final : ...

Boost库Json使用

#include <iostream> #include "boost/json/src.hpp" // 构造json void create_json() { boost::json::object val; val["a_string"] = "helloworld"; val["a_number"] = 123; val["a_null"] = nullptr; val["a_array"] = {1, &q...