Commit e5aff4b4 authored by Adam Reichold's avatar Adam Reichold Committed by Albert Astals Cid

Remove MULTITHREADED build flag, i.e. always enable threading support based on...

Remove MULTITHREADED build flag, i.e. always enable threading support based on the C++ standard library and make use of RAII lockers for GlobalParams.
parent a38895a1
Pipeline #4668 failed with stage
in 2 minutes and 10 seconds
......@@ -109,10 +109,6 @@ else()
message(FATAL_ERROR "Invalid font configuration setting: ${FONT_CONFIGURATION}")
endif()
if(CMAKE_USE_PTHREADS_INIT OR WIN32)
set(MULTITHREADED ON)
endif()
# Enable these unconditionally.
set(OPI_SUPPORT ON)
set(TEXTOUT_WORD_LIST ON)
......
......@@ -126,9 +126,6 @@
/* Define as const if the declaration of iconv() needs const. */
#define ICONV_CONST ${ICONV_CONST}
/* Enable multithreading support. */
#cmakedefine MULTITHREADED 1
/* Generate OPI comments in PS output. */
#cmakedefine OPI_SUPPORT 1
......
......@@ -82,12 +82,6 @@
#include <string.h>
#include <algorithm>
#ifdef MULTITHREADED
# define annotLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
#else
# define annotLocker()
#endif
#define fieldFlagReadOnly 0x00000001
#define fieldFlagRequired 0x00000002
#define fieldFlagNoExport 0x00000004
......@@ -1220,6 +1214,8 @@ double AnnotAppearanceBBox::getPageYMax() const {
// Annot
//------------------------------------------------------------------------
#define annotLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
Annot::Annot(PDFDoc *docA, PDFRectangle *rectA) {
refCnt = 1;
......
......@@ -769,9 +769,7 @@ protected:
GBool ok;
bool hasRef;
#ifdef MULTITHREADED
mutable std::recursive_mutex mutex;
#endif
};
//------------------------------------------------------------------------
......
......@@ -38,15 +38,12 @@
#include "Object.h"
#include "Array.h"
#ifdef MULTITHREADED
# define arrayLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
#else
# define arrayLocker()
#endif
//------------------------------------------------------------------------
// Array
//------------------------------------------------------------------------
#define arrayLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
Array::Array(XRef *xrefA) {
xref = xrefA;
elems = nullptr;
......
......@@ -85,9 +85,7 @@ private:
int size; // size of <elems> array
int length; // number of elements in array
std::atomic_int ref; // reference count
#ifdef MULTITHREADED
mutable std::recursive_mutex mutex;
#endif
};
#endif
......@@ -60,12 +60,6 @@
#pragma implementation
#endif
#ifdef MULTITHREADED
# define fontEngineLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
#else
# define fontEngineLocker()
#endif
//------------------------------------------------------------------------
// CairoFont
//------------------------------------------------------------------------
......@@ -802,6 +796,8 @@ CairoType3Font::matches(Ref &other, GBool printingA) {
// CairoFontEngine
//------------------------------------------------------------------------
#define fontEngineLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
CairoFontEngine::CairoFontEngine(FT_Library libA) {
int i;
......
......@@ -127,9 +127,7 @@ private:
CairoFont *fontCache[cairoFontCacheSize];
FT_Library lib;
GBool useCIDs;
#ifdef MULTITHREADED
mutable std::recursive_mutex mutex;
#endif
};
#endif
......@@ -66,15 +66,12 @@
#include "FileSpec.h"
#include "StructTreeRoot.h"
#ifdef MULTITHREADED
# define catalogLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
#else
# define catalogLocker()
#endif
//------------------------------------------------------------------------
// Catalog
//------------------------------------------------------------------------
#define catalogLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
Catalog::Catalog(PDFDoc *docA) {
ok = gTrue;
doc = docA;
......
......@@ -291,10 +291,8 @@ private:
NameTree *getEmbeddedFileNameTree();
NameTree *getJSNameTree();
LinkDest *createLinkDest(Object *obj);
#ifdef MULTITHREADED
mutable std::recursive_mutex mutex;
#endif
mutable std::recursive_mutex mutex;
};
#endif
......@@ -40,15 +40,12 @@
#include "XRef.h"
#include "Dict.h"
#ifdef MULTITHREADED
# define dictLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
#else
# define dictLocker()
#endif
//------------------------------------------------------------------------
// Dict
//------------------------------------------------------------------------
#define dictLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
constexpr int SORT_LENGTH_LOWER_LIMIT = 32;
struct Dict::CmpDictEntry {
......
......@@ -111,9 +111,7 @@ private:
XRef *xref; // the xref table for this PDF file
std::vector<DictEntry> entries;
std::atomic_int ref; // reference count
#ifdef MULTITHREADED
mutable std::recursive_mutex mutex;
#endif
const DictEntry *find(const char *key) const;
DictEntry *find(const char *key);
......
This diff is collapsed.
......@@ -242,11 +242,9 @@ private:
// [XpdfSecurityHandler]
#endif
#ifdef MULTITHREADED
mutable std::recursive_mutex mutex;
mutable std::recursive_mutex unicodeMapCacheMutex;
mutable std::recursive_mutex cMapCacheMutex;
#endif
const char *popplerDataDir;
};
......
......@@ -54,22 +54,6 @@ description for all fonts available in Windows. That's how MuPDF works.
#include "Lexer.h"
#include "Parser.h"
#ifdef MULTITHREADED
# define lockGlobalParams gLockMutex(&mutex)
# define lockUnicodeMapCache gLockMutex(&unicodeMapCacheMutex)
# define lockCMapCache gLockMutex(&cMapCacheMutex)
# define unlockGlobalParams gUnlockMutex(&mutex)
# define unlockUnicodeMapCache gUnlockMutex(&unicodeMapCacheMutex)
# define unlockCMapCache gUnlockMutex(&cMapCacheMutex)
#else
# define lockGlobalParams
# define lockUnicodeMapCache
# define lockCMapCache
# define unlockGlobalParams
# define unlockUnicodeMapCache
# define unlockCMapCache
#endif
#define DEFAULT_SUBSTITUTE_FONT "Helvetica"
#define DEFAULT_CID_FONT_AC1_MSWIN "MingLiU" /* Adobe-CNS1 for Taiwan, HongKong */
#define DEFAULT_CID_FONT_AG1_MSWIN "SimSun" /* Adobe-GB1 for PRC, Singapore */
......@@ -556,7 +540,7 @@ GooString *GlobalParams::findSystemFontFile(GfxFont *font,
GooString *path = nullptr;
const GooString *fontName = font->getName();
if (!fontName) return nullptr;
lockGlobalParams;
std::unique_lock<std::recursive_mutex> locker(mutex);
setupBaseFonts(nullptr);
// TODO: base14Name should be changed?
......@@ -587,6 +571,6 @@ GooString *GlobalParams::findSystemFontFile(GfxFont *font,
*fontNum = 0;
}
}
unlockGlobalParams;
return path;
}
......@@ -91,12 +91,6 @@
#include "Hints.h"
#include "UTF.h"
#ifdef MULTITHREADED
# define pdfdocLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
#else
# define pdfdocLocker()
#endif
//------------------------------------------------------------------------
#define headerSearchSize 1024 // read this many bytes at beginning of
......@@ -114,6 +108,8 @@
// PDFDoc
//------------------------------------------------------------------------
#define pdfdocLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
void PDFDoc::init()
{
ok = gFalse;
......
......@@ -433,9 +433,7 @@ private:
int fopenErrno;
Goffset startXRefPos; // offset of last xref table
#ifdef MULTITHREADED
mutable std::recursive_mutex mutex;
#endif
};
#endif
......@@ -61,11 +61,6 @@
#include "Catalog.h"
#include "Form.h"
#ifdef MULTITHREADED
# define pageLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
#else
# define pageLocker()
#endif
//------------------------------------------------------------------------
// PDFRectangle
//------------------------------------------------------------------------
......@@ -248,6 +243,8 @@ GBool PageAttrs::readBox(Dict *dict, const char *key, PDFRectangle *box) {
// Page
//------------------------------------------------------------------------
#define pageLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
Page::Page(PDFDoc *docA, int numA, Object *pageDict, Ref pageRefA, PageAttrs *attrsA, Form *form) {
ok = gTrue;
doc = docA;
......
......@@ -286,9 +286,7 @@ private:
Object actions; // page additional actions
double duration; // page duration
GBool ok; // true if page is valid
#ifdef MULTITHREADED
mutable std::recursive_mutex mutex;
#endif
};
#endif
......@@ -72,12 +72,6 @@
#define permHighResPrint (1<<11) // bit 12
#define defPermFlags 0xfffc
#ifdef MULTITHREADED
# define xrefLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
#else
# define xrefLocker()
#endif
//------------------------------------------------------------------------
// ObjectStream
//------------------------------------------------------------------------
......@@ -262,6 +256,8 @@ Object ObjectStream::getObject(int objIdx, int objNum) {
// XRef
//------------------------------------------------------------------------
#define xrefLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
void XRef::init() {
ok = gTrue;
errCode = errNone;
......@@ -1233,15 +1229,11 @@ Object XRef::fetch(int num, int gen, int recursion) {
}
void XRef::lock() {
#ifdef MULTITHREADED
mutex.lock();
#endif
}
void XRef::unlock() {
#ifdef MULTITHREADED
mutex.unlock();
#endif
}
Object XRef::getDocInfo() {
......
......@@ -237,9 +237,7 @@ private:
Goffset mainXRefOffset; // position of the main XRef table/stream
GBool scannedSpecialFlags; // true if scanSpecialFlags has been called
GBool strOwner; // true if str is owned by the instance
#ifdef MULTITHREADED
mutable std::recursive_mutex mutex;
#endif
void init();
int reserve(int newSize);
......
......@@ -37,11 +37,6 @@
#define POPPLER_VERSION "${POPPLER_VERSION}"
#endif
/* Enable multithreading support. */
#ifndef MULTITHREADED
#cmakedefine MULTITHREADED 1
#endif
/* Use fixedpoint. */
#ifndef USE_FIXEDPOINT
#cmakedefine USE_FIXEDPOINT 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment