Added thread pool to parallelize diagram generation
This commit is contained in:
@@ -35,7 +35,7 @@ thread_pool_executor::thread_pool_executor(unsigned int pool_size)
|
||||
}
|
||||
}
|
||||
|
||||
~thread_pool_executor::thread_pool_executor() { stop(); }
|
||||
thread_pool_executor::~thread_pool_executor() { stop(); }
|
||||
|
||||
std::future<void> thread_pool_executor::add(std::function<void()> &&task)
|
||||
{
|
||||
|
||||
@@ -26,6 +26,18 @@ namespace util {
|
||||
|
||||
const std::string WHITESPACE = " \n\r\t\f\v";
|
||||
|
||||
void setup_logging(bool verbose)
|
||||
{
|
||||
auto console =
|
||||
spdlog::stdout_color_mt("console", spdlog::color_mode::automatic);
|
||||
|
||||
console->set_pattern("[%^%l%^] [tid %t] %v");
|
||||
|
||||
if (verbose) {
|
||||
console->set_level(spdlog::level::debug);
|
||||
}
|
||||
}
|
||||
|
||||
std::string ltrim(const std::string &s)
|
||||
{
|
||||
size_t start = s.find_first_not_of(WHITESPACE);
|
||||
@@ -68,34 +80,6 @@ std::string join(const std::vector<std::string> &toks, std::string delimiter)
|
||||
return fmt::format("{}", fmt::join(toks, delimiter));
|
||||
}
|
||||
|
||||
/*
|
||||
std::string ns_relative(
|
||||
const std::vector<std::string> &namespaces, const std::string &n)
|
||||
{
|
||||
std::vector<std::string> namespaces_sorted{namespaces};
|
||||
|
||||
std::sort(namespaces_sorted.rbegin(), namespaces_sorted.rend());
|
||||
|
||||
auto res = n;
|
||||
|
||||
for (const auto &ns : namespaces_sorted) {
|
||||
if (ns.empty())
|
||||
continue;
|
||||
|
||||
if (n == ns)
|
||||
return split(n, "::").back();
|
||||
|
||||
auto ns_prefix = ns + "::";
|
||||
auto it = res.find(ns_prefix);
|
||||
while (it != std::string::npos) {
|
||||
res.erase(it, ns_prefix.size());
|
||||
it = res.find(ns_prefix);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
*/
|
||||
|
||||
std::string unqualify(const std::string &s)
|
||||
{
|
||||
auto toks = clanguml::util::split(s, " ");
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -36,20 +37,27 @@ std::string trim(const std::string &s);
|
||||
(strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
|
||||
#define LOG_ERROR(fmt__, ...) \
|
||||
spdlog::error(std::string("[{}:{}] ") + fmt__, __FILENAME__, __LINE__, \
|
||||
##__VA_ARGS__)
|
||||
spdlog::get("console")->error(std::string("[{}:{}] ") + fmt__, \
|
||||
__FILENAME__, __LINE__, ##__VA_ARGS__)
|
||||
|
||||
#define LOG_WARN(fmt__, ...) \
|
||||
spdlog::warn(std::string("[{}:{}] ") + fmt__, __FILENAME__, __LINE__, \
|
||||
##__VA_ARGS__)
|
||||
spdlog::get("console")->warn(std::string("[{}:{}] ") + fmt__, \
|
||||
__FILENAME__, __LINE__, ##__VA_ARGS__)
|
||||
|
||||
#define LOG_INFO(fmt__, ...) \
|
||||
spdlog::info(std::string("[{}:{}] ") + fmt__, __FILENAME__, __LINE__, \
|
||||
##__VA_ARGS__)
|
||||
spdlog::get("console")->info(std::string("[{}:{}] ") + fmt__, \
|
||||
__FILENAME__, __LINE__, ##__VA_ARGS__)
|
||||
|
||||
#define LOG_DBG(fmt__, ...) \
|
||||
spdlog::debug(std::string("[{}:{}] ") + fmt__, __FILENAME__, __LINE__, \
|
||||
##__VA_ARGS__)
|
||||
spdlog::get("console")->debug(std::string("[{}:{}] ") + fmt__, \
|
||||
__FILENAME__, __LINE__, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Setup spdlog logger.
|
||||
*
|
||||
* @param verbose Whether the logging should be verbose or not.
|
||||
*/
|
||||
void setup_logging(bool verbose);
|
||||
|
||||
/**
|
||||
* @brief Split a string using delimiter
|
||||
@@ -67,25 +75,6 @@ std::vector<std::string> split(std::string str, std::string delimiter);
|
||||
|
||||
std::string join(const std::vector<std::string> &toks, std::string delimiter);
|
||||
|
||||
/**
|
||||
* @brief Get name of the identifier relative to a set of namespaces
|
||||
*
|
||||
* This function tries to match a given C++ identifier (e.g.
|
||||
* clanguml::util::split) to the longest namespace from the provided list
|
||||
* matching the identifier from the left.
|
||||
* If a match is found, the relative identifier is returned. If none of
|
||||
* the namespaces match the identifier or if nothing is left after
|
||||
* removing the matching namespace from the identifier, original identifier is
|
||||
* returned.
|
||||
*
|
||||
* @param namespaces List of C++ namespaces to consider
|
||||
* @param n Identifier to relativize
|
||||
*
|
||||
* @return Identifier relative to one of the matching namespaces.
|
||||
*/
|
||||
// std::string ns_relative(
|
||||
// const std::vector<std::string> &namespaces, const std::string &n);
|
||||
|
||||
/**
|
||||
* @brief Remove any qualifiers (e.g. const) from type.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user