Replaced pthread with std:: thread and mutex

This commit is contained in:
Jean-Francois Dockes
2016-07-12 18:08:21 +02:00
parent d8f215b6ed
commit c1fad4afc7
33 changed files with 367 additions and 633 deletions
+2 -2
View File
@@ -22,7 +22,7 @@
#include "log.h"
#include "internfile.h"
PTMutexInit DocSequence::o_dblock;
std::mutex DocSequence::o_dblock;
string DocSequence::o_sort_trans;
string DocSequence::o_filt_trans;
@@ -46,7 +46,7 @@ bool DocSequence::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc)
LOGERR("DocSequence::getEnclosing: no db\n" );
return false;
}
PTMutexLocker locker(o_dblock);
std::unique_lock<std::mutex> locker(o_dblock);
string udi;
if (!FileInterner::getEnclosingUDI(doc, udi))
return false;
+3 -3
View File
@@ -22,11 +22,11 @@
#include <string>
#include <list>
#include <vector>
#include MEMORY_INCLUDE
#include <mutex>
#include <memory>
#include "rcldoc.h"
#include "hldata.h"
#include "ptmutex.h"
// Need this for the "Snippet" class def.
#include "rclquery.h"
@@ -167,7 +167,7 @@ class DocSequence {
protected:
friend class DocSeqModifier;
virtual Rcl::Db *getDb() = 0;
static PTMutexInit o_dblock;
static std::mutex o_dblock;
static std::string o_sort_trans;
static std::string o_filt_trans;
std::string m_reason;
+9 -9
View File
@@ -53,7 +53,7 @@ string DocSequenceDb::getDescription()
bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, string *sh)
{
PTMutexLocker locker(o_dblock);
std::unique_lock<std::mutex> locker(o_dblock);
if (!setQuery())
return false;
if (sh) sh->erase();
@@ -62,7 +62,7 @@ bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, string *sh)
int DocSequenceDb::getResCnt()
{
PTMutexLocker locker(o_dblock);
std::unique_lock<std::mutex> locker(o_dblock);
if (!setQuery())
return false;
if (m_rescnt < 0) {
@@ -78,7 +78,7 @@ static const string cstr_mre("[...]");
bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<Rcl::Snippet>& vpabs)
{
LOGDEB("DocSequenceDb::getAbstract/pair\n" );
PTMutexLocker locker(o_dblock);
std::unique_lock<std::mutex> locker(o_dblock);
if (!setQuery())
return false;
@@ -108,7 +108,7 @@ bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<Rcl::Snippet>& vpabs)
bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<string>& vabs)
{
PTMutexLocker locker(o_dblock);
std::unique_lock<std::mutex> locker(o_dblock);
if (!setQuery())
return false;
if (m_q->whatDb() &&
@@ -122,7 +122,7 @@ bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<string>& vabs)
int DocSequenceDb::getFirstMatchPage(Rcl::Doc &doc, string& term)
{
PTMutexLocker locker(o_dblock);
std::unique_lock<std::mutex> locker(o_dblock);
if (!setQuery())
return false;
if (m_q->whatDb()) {
@@ -138,7 +138,7 @@ Rcl::Db *DocSequenceDb::getDb()
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
{
PTMutexLocker locker(o_dblock);
std::unique_lock<std::mutex> locker(o_dblock);
if (!setQuery())
return list<string>();
vector<string> v = m_q->expand(doc);
@@ -161,7 +161,7 @@ string DocSequenceDb::title()
bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
{
LOGDEB("DocSequenceDb::setFiltSpec\n" );
PTMutexLocker locker(o_dblock);
std::unique_lock<std::mutex> locker(o_dblock);
if (fs.isNotNull()) {
// We build a search spec by adding a filtering layer to the base one.
m_fsdata = STD_SHARED_PTR<Rcl::SearchData>(
@@ -209,7 +209,7 @@ bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
bool DocSequenceDb::setSortSpec(const DocSeqSortSpec &spec)
{
LOGDEB("DocSequenceDb::setSortSpec: fld [" << (spec.field) << "] " << (spec.desc ? "desc" : "asc") << "\n" );
PTMutexLocker locker(o_dblock);
std::unique_lock<std::mutex> locker(o_dblock);
if (spec.isNotNull()) {
m_q->setSortBy(spec.field, !spec.desc);
m_isSorted = true;
@@ -239,7 +239,7 @@ bool DocSequenceDb::setQuery()
bool DocSequenceDb::docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups)
{
if (m_q->whatDb()) {
PTMutexLocker locker(o_dblock);
std::unique_lock<std::mutex> locker(o_dblock);
return m_q->whatDb()->docDups(doc, dups);
} else {
return false;