try to fix Issue 221: Segfaulting RT. severe mem leak in thumb threading
This commit is contained in:
@@ -19,11 +19,19 @@
|
|||||||
#include <thumbimageupdater.h>
|
#include <thumbimageupdater.h>
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
|
#define threadNum 4 // IF LCMS GETS THREAD SAFETY WE CAN ENABLE MORE THREADS
|
||||||
ThumbImageUpdater thumbImageUpdater;
|
ThumbImageUpdater thumbImageUpdater;
|
||||||
|
|
||||||
ThumbImageUpdater::ThumbImageUpdater ()
|
ThumbImageUpdater::ThumbImageUpdater ()
|
||||||
: tostop(false), stopped(true), qMutex(NULL), startMutex(NULL) {
|
: tostop(false), stopped(true), qMutex(NULL), startMutex(NULL) {
|
||||||
|
|
||||||
|
threadPool = new Glib::Thread* [threadNum];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ThumbImageUpdater::~ThumbImageUpdater ()
|
||||||
|
{
|
||||||
|
delete threadPool;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThumbImageUpdater::add (Thumbnail* t, const rtengine::procparams::ProcParams& params, int height, bool* priority, ThumbImageUpdateListener* l) {
|
void ThumbImageUpdater::add (Thumbnail* t, const rtengine::procparams::ProcParams& params, int height, bool* priority, ThumbImageUpdateListener* l) {
|
||||||
@@ -59,9 +67,9 @@ void ThumbImageUpdater::add (Thumbnail* t, const rtengine::procparams::ProcParam
|
|||||||
void ThumbImageUpdater::process () {
|
void ThumbImageUpdater::process () {
|
||||||
|
|
||||||
if (stopped) {
|
if (stopped) {
|
||||||
#undef THREAD_PRIORITY_NORMAL
|
#undef THREAD_PRIORITY_LOW
|
||||||
stopped = false;
|
stopped = false;
|
||||||
thread = Glib::Thread::create(sigc::mem_fun(*this, &ThumbImageUpdater::process_), (unsigned long int)0, true, true, Glib::THREAD_PRIORITY_NORMAL);
|
thread = Glib::Thread::create(sigc::mem_fun(*this, &ThumbImageUpdater::process_), (unsigned long int)0, true, true, Glib::THREAD_PRIORITY_LOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,8 +78,6 @@ void ThumbImageUpdater::process_ () {
|
|||||||
stopped = false;
|
stopped = false;
|
||||||
tostop = false;
|
tostop = false;
|
||||||
|
|
||||||
#define threadNum 4 // IF LCMS GETS THREAD SAFETY WE CAN ENABLE MORE THREADS
|
|
||||||
Glib::Thread **threadPool = new Glib::Thread* [threadNum];
|
|
||||||
|
|
||||||
while (!tostop && !jqueue.empty ()) {
|
while (!tostop && !jqueue.empty ()) {
|
||||||
|
|
||||||
@@ -88,15 +94,18 @@ void ThumbImageUpdater::process_ () {
|
|||||||
Job current = *i;
|
Job current = *i;
|
||||||
jqueue.erase (i);
|
jqueue.erase (i);
|
||||||
if (current.listener)
|
if (current.listener)
|
||||||
threadPool[threads] = Glib::Thread::create(sigc::bind(sigc::mem_fun(*this, &ThumbImageUpdater::processJob), current), 0, true, true, Glib::THREAD_PRIORITY_NORMAL);
|
threadPool[threads] = Glib::Thread::create(sigc::bind(sigc::mem_fun(*this, &ThumbImageUpdater::processJob), current), 0, true, true, Glib::THREAD_PRIORITY_LOW);
|
||||||
else
|
//else
|
||||||
threadPool[threads] = NULL;
|
// threadPool[threads] = NULL;
|
||||||
}
|
}
|
||||||
qMutex->unlock ();
|
qMutex->unlock ();
|
||||||
|
|
||||||
for (int j=0; j<threads; j++)
|
for (int j=0; j<threads; j++)
|
||||||
if (threadPool[j])
|
if (threadPool[j])
|
||||||
threadPool[j]->join ();
|
threadPool[j]->join ();
|
||||||
|
|
||||||
|
for(int j =0; j <threadNum;j++)
|
||||||
|
threadPool[j] = NULL;
|
||||||
}
|
}
|
||||||
stopped = true;
|
stopped = true;
|
||||||
}
|
}
|
||||||
|
@@ -46,9 +46,11 @@ class ThumbImageUpdater {
|
|||||||
Glib::Thread* thread;
|
Glib::Thread* thread;
|
||||||
Glib::Mutex* qMutex;
|
Glib::Mutex* qMutex;
|
||||||
Glib::Mutex* startMutex;
|
Glib::Mutex* startMutex;
|
||||||
|
Glib::Thread **threadPool;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ThumbImageUpdater ();
|
ThumbImageUpdater ();
|
||||||
|
~ThumbImageUpdater ();
|
||||||
|
|
||||||
void add (Thumbnail* t, const rtengine::procparams::ProcParams& params, int height, bool* priority, ThumbImageUpdateListener* l);
|
void add (Thumbnail* t, const rtengine::procparams::ProcParams& params, int height, bool* priority, ThumbImageUpdateListener* l);
|
||||||
void process ();
|
void process ();
|
||||||
|
Reference in New Issue
Block a user