diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2020-06-17 18:49:11 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2020-06-17 18:49:11 (GMT) |
commit | d0f24b762e23b1b0c069209978aa403acc027cdf (patch) | |
tree | 0d4d9deffeb4d0b2a809b1807dc52d88bf5d80e9 /src/commentscan.l | |
parent | 46672f1e6ea2c63e54c0fc8420d6ebdaca958478 (diff) | |
download | Doxygen-d0f24b762e23b1b0c069209978aa403acc027cdf.zip Doxygen-d0f24b762e23b1b0c069209978aa403acc027cdf.tar.gz Doxygen-d0f24b762e23b1b0c069209978aa403acc027cdf.tar.bz2 |
Multi-threaded parsing: added locks around global data
Diffstat (limited to 'src/commentscan.l')
-rw-r--r-- | src/commentscan.l | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/src/commentscan.l b/src/commentscan.l index f521528..12391cb 100644 --- a/src/commentscan.l +++ b/src/commentscan.l @@ -30,6 +30,7 @@ #include <map> #include <stack> #include <string> +#include <mutex> #include <stdio.h> #include <stdlib.h> @@ -401,6 +402,13 @@ struct commentscanYY_state bool markdownSupport = TRUE; }; + +#if MULTITHREADED_INPUT +static std::mutex g_sectionMutex; +static std::mutex g_formulaMutex; +static std::mutex g_citeMutex; +#endif + //----------------------------------------------------------------------------- static QCString stripQuotes(const char *s); @@ -2786,6 +2794,10 @@ static void addXRefItem(yyscan_t yyscanner, if (listName==0) return; //printf("addXRefItem(%s,%s,%s,%d)\n",listName,itemTitle,listTitle,append); +#if MULTITHREADED_INPUT + std::unique_lock<std::mutex> lock(g_sectionMutex); +#endif + RefList *refList = RefListManager::instance().add(listName,listTitle,itemTitle); RefItem *item = 0; for (RefItem *i : yyextra->current->sli) @@ -2826,26 +2838,28 @@ static void addXRefItem(yyscan_t yyscanner, yyextra->current->doc += cmdString; } - SectionManager &sm = SectionManager::instance(); - const SectionInfo *si = sm.find(anchorLabel); - if (si) { - if (si->lineNr() != -1) + SectionManager &sm = SectionManager::instance(); + const SectionInfo *si = sm.find(anchorLabel); + if (si) { - warn(listName,yyextra->lineNr,"multiple use of section label '%s', (first occurrence: %s, line %d)",anchorLabel.data(),si->fileName().data(),si->lineNr()); + if (si->lineNr() != -1) + { + warn(listName,yyextra->lineNr,"multiple use of section label '%s', (first occurrence: %s, line %d)",anchorLabel.data(),si->fileName().data(),si->lineNr()); + } + else + { + warn(listName,yyextra->lineNr,"multiple use of section label '%s', (first occurrence: %s)",anchorLabel.data(),si->fileName().data()); + } } else { - warn(listName,yyextra->lineNr,"multiple use of section label '%s', (first occurrence: %s)",anchorLabel.data(),si->fileName().data()); + si = sm.add(anchorLabel,listName,yyextra->lineNr, + yyextra->sectionTitle,SectionType::Anchor, + yyextra->sectionLevel); + yyextra->current->anchors.push_back(si); } } - else - { - si = sm.add(anchorLabel,listName,yyextra->lineNr, - yyextra->sectionTitle,SectionType::Anchor, - yyextra->sectionLevel); - yyextra->current->anchors.push_back(si); - } } yyextra->outputXRef.resize(0); } @@ -2856,6 +2870,9 @@ static void addXRefItem(yyscan_t yyscanner, // not already added. Returns the label of the formula. static QCString addFormula(yyscan_t yyscanner) { +#if MULTITHREADED_INPUT + std::unique_lock<std::mutex> lock(g_formulaMutex); +#endif struct yyguts_t *yyg = (struct yyguts_t*)yyscanner; QCString formLabel; QCString fText=yyextra->formulaText.simplifyWhiteSpace(); @@ -2877,6 +2894,9 @@ static SectionType sectionLevelToType(int level) static void addSection(yyscan_t yyscanner) { +#if MULTITHREADED_INPUT + std::unique_lock<std::mutex> lock(g_sectionMutex); +#endif struct yyguts_t *yyg = (struct yyguts_t*)yyscanner; SectionManager &sm = SectionManager::instance(); const SectionInfo *si = sm.find(yyextra->sectionLabel); @@ -2909,6 +2929,9 @@ static void addSection(yyscan_t yyscanner) static void addCite(yyscan_t yyscanner) { +#if MULTITHREADED_INPUT + std::unique_lock<std::mutex> lock(g_citeMutex); +#endif struct yyguts_t *yyg = (struct yyguts_t*)yyscanner; QCString name=yytext; if (yytext[0] =='"') @@ -3060,6 +3083,9 @@ static inline void setOutput(yyscan_t yyscanner,OutputContext ctx) static void addAnchor(yyscan_t yyscanner,const char *anchor) { +#if MULTITHREADED_INPUT + std::unique_lock<std::mutex> lock(g_sectionMutex); +#endif struct yyguts_t *yyg = (struct yyguts_t*)yyscanner; SectionManager &sm = SectionManager::instance(); const SectionInfo *si = sm.find(anchor); |