From f5ab6fb5e8be7b73e6003d4145081d5e0c0ce287 Mon Sep 17 00:00:00 2001 From: Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> Date: Wed, 27 Dec 2023 00:32:01 +0000 Subject: Folder restructuring from primedev (#624) Copies of over the primedev folder structure for easier cherry-picking of further changes Co-authored-by: F1F7Y --- thirdparty/spdlog/async.h | 93 ----------------------------------------------- 1 file changed, 93 deletions(-) delete mode 100644 thirdparty/spdlog/async.h (limited to 'thirdparty/spdlog/async.h') diff --git a/thirdparty/spdlog/async.h b/thirdparty/spdlog/async.h deleted file mode 100644 index f7956305..00000000 --- a/thirdparty/spdlog/async.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright(c) 2015-present, Gabi Melman & spdlog contributors. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) - -#pragma once - -// -// Async logging using global thread pool -// All loggers created here share same global thread pool. -// Each log message is pushed to a queue along with a shared pointer to the -// logger. -// If a logger deleted while having pending messages in the queue, it's actual -// destruction will defer -// until all its messages are processed by the thread pool. -// This is because each message in the queue holds a shared_ptr to the -// originating logger. - -#include -#include -#include - -#include -#include -#include - -namespace spdlog { - -namespace details { -static const size_t default_async_q_size = 8192; -} - -// async logger factory - creates async loggers backed with thread pool. -// if a global thread pool doesn't already exist, create it with default queue -// size of 8192 items and single thread. -template -struct async_factory_impl -{ - template - static std::shared_ptr create(std::string logger_name, SinkArgs &&...args) - { - auto ®istry_inst = details::registry::instance(); - - // create global thread pool if not already exists.. - - auto &mutex = registry_inst.tp_mutex(); - std::lock_guard tp_lock(mutex); - auto tp = registry_inst.get_tp(); - if (tp == nullptr) - { - tp = std::make_shared(details::default_async_q_size, 1); - registry_inst.set_tp(tp); - } - - auto sink = std::make_shared(std::forward(args)...); - auto new_logger = std::make_shared(std::move(logger_name), std::move(sink), std::move(tp), OverflowPolicy); - registry_inst.initialize_logger(new_logger); - return new_logger; - } -}; - -using async_factory = async_factory_impl; -using async_factory_nonblock = async_factory_impl; - -template -inline std::shared_ptr create_async(std::string logger_name, SinkArgs &&...sink_args) -{ - return async_factory::create(std::move(logger_name), std::forward(sink_args)...); -} - -template -inline std::shared_ptr create_async_nb(std::string logger_name, SinkArgs &&...sink_args) -{ - return async_factory_nonblock::create(std::move(logger_name), std::forward(sink_args)...); -} - -// set global thread pool. -inline void init_thread_pool(size_t q_size, size_t thread_count, std::function on_thread_start) -{ - auto tp = std::make_shared(q_size, thread_count, on_thread_start); - details::registry::instance().set_tp(std::move(tp)); -} - -// set global thread pool. -inline void init_thread_pool(size_t q_size, size_t thread_count) -{ - init_thread_pool(q_size, thread_count, [] {}); -} - -// get the global thread pool. -inline std::shared_ptr thread_pool() -{ - return details::registry::instance().get_tp(); -} -} // namespace spdlog -- cgit v1.2.3