diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2020-05-31 17:58:24 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2020-05-31 17:58:24 (GMT) |
commit | b265433382b93625b75cbc1f10b0509489b0b6b7 (patch) | |
tree | 896cdcd7e1a9f8c696fa7cf3535be906d2ad31d7 /src/util.cpp | |
parent | 1705a1442dfa83d6c442bb45ed0d6e76f135ee5a (diff) | |
download | Doxygen-b265433382b93625b75cbc1f10b0509489b0b6b7.zip Doxygen-b265433382b93625b75cbc1f10b0509489b0b6b7.tar.gz Doxygen-b265433382b93625b75cbc1f10b0509489b0b6b7.tar.bz2 |
Added experimental multi-thread input processing support.
This is disabled by default. It can be enabled by setting MULTITHREADED_INPUT to 1
in doxygen.h. Still has many data races, so don't use for anything other than development!
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/util.cpp b/src/util.cpp index d198a5d..86435fa 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -22,6 +22,7 @@ #include <cinttypes> #include <string.h> +#include <mutex> #include "md5.h" @@ -1664,15 +1665,16 @@ static CharAroundSpace g_charAroundSpace; // Note: this function is not reentrant due to the use of static buffer! QCString removeRedundantWhiteSpace(const QCString &s) { - static bool cliSupport = Config_getBool(CPP_CLI_SUPPORT); - static bool vhdl = Config_getBool(OPTIMIZE_OUTPUT_VHDL); + bool cliSupport = Config_getBool(CPP_CLI_SUPPORT); + bool vhdl = Config_getBool(OPTIMIZE_OUTPUT_VHDL); if (s.isEmpty() || vhdl) return s; // We use a static character array to // improve the performance of this function - static char *growBuf = 0; - static int growBufLen = 0; + // and thread_local is needed to make it multi-thread safe + static THREAD_LOCAL char *growBuf = 0; + static THREAD_LOCAL int growBufLen = 0; if ((int)s.length()*3>growBufLen) // For input character we produce at most 3 output characters, { growBufLen = s.length()*3; @@ -4480,11 +4482,19 @@ struct FindFileCacheElem static QCache<FindFileCacheElem> g_findFileDefCache(5000); +#if MULTITHREADED_INPUT +static std::mutex g_findFileDefMutex; +#endif + FileDef *findFileDef(const FileNameLinkedMap *fnMap,const char *n,bool &ambig) { ambig=FALSE; if (n==0) return 0; +#if MULTITHREADED_INPUT + std::unique_lock<std::mutex> lock(g_findFileDefMutex); +#endif + const int maxAddrSize = 20; char addr[maxAddrSize]; qsnprintf(addr,maxAddrSize,"%p:",(void*)fnMap); |