Skip to content

Commit

Permalink
Merged master into gtk3, manually copied rtgui/threadutils.h over fro…
Browse files Browse the repository at this point in the history
…m master
  • Loading branch information
Beep6581 committed Jan 30, 2016
2 parents 978e9f6 + 4d3f1d9 commit f5d5083
Show file tree
Hide file tree
Showing 12 changed files with 499 additions and 768 deletions.
7 changes: 0 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ option (WITH_BZIP "Build with Bzip2 support" ON)
option (WITH_MYFILE_MMAP "Build using memory mapped file" ON)
option (WITH_LTO "Build with link-time optimizations" OFF)
option (OPTION_OMP "Build with OpenMP support" ON)
option (PROTECT_VECTORS "Protect critical vectors by custom R/W Mutex, recommanded even if your std::vector is thread safe" ON)
option (STRICT_MUTEX "True (recommended): MyMutex will behave like POSIX Mutex; False: MyMutex will behave like POSIX RecMutex; Note: forced to ON for Debug builds" ON)
option (TRACE_MYRWMUTEX "Trace RT's custom R/W Mutex (Debug builds only); redirecting std::out to a file is strongly recommended!" OFF)
option (AUTO_GDK_FLUSH "Use gdk_flush on all gdk_thread_leave other than the GUI thread; set it ON if you experience X Server warning/errors" OFF)
Expand Down Expand Up @@ -204,13 +203,7 @@ else (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
endif (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG")

# MyRWMutex
if (PROTECT_VECTORS)
add_definitions (-DPROTECT_VECTORS=1)
else (PROTECT_VECTORS)
add_definitions (-DPROTECT_VECTORS=0)
endif (PROTECT_VECTORS)
if (TRACE_MYRWMUTEX)
# Note: it will be set to 0 for Debug builds (rtgui/guiutils.h)
add_definitions (-DTRACE_MYRWMUTEX=1)
else (TRACE_MYRWMUTEX)
add_definitions (-DTRACE_MYRWMUTEX=0)
Expand Down
2 changes: 1 addition & 1 deletion rtgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set (BASESOURCEFILES
preferences.cc profilepanel.cc saveasdlg.cc
saveformatpanel.cc soundman.cc splash.cc
thumbnail.cc tonecurve.cc toolbar.cc
guiutils.cc zoompanel.cc toolpanelcoord.cc
guiutils.cc threadutils.cc zoompanel.cc toolpanelcoord.cc
thumbbrowserentrybase.cc batchqueueentry.cc
batchqueue.cc lwbutton.cc lwbuttonset.cc
batchqueuebuttonset.cc browserfilter.cc exiffiltersettings.cc
Expand Down
41 changes: 3 additions & 38 deletions rtgui/batchqueue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ BatchQueue::BatchQueue (FileCatalog* aFileCatalog) : processing(NULL), fileCatal

BatchQueue::~BatchQueue ()
{
#if PROTECT_VECTORS
MYWRITERLOCK(l, entryRW);
#endif

// The listener merges parameters with old values, so delete afterwards
for (size_t i = 0; i < fd.size(); i++) {
Expand All @@ -100,9 +98,7 @@ BatchQueue::~BatchQueue ()

void BatchQueue::resizeLoadedQueue()
{
#if PROTECT_VECTORS
MYWRITERLOCK(l, entryRW);
#endif

const auto height = getThumbnailHeight ();

Expand Down Expand Up @@ -171,9 +167,7 @@ bool BatchQueue::keyPressed (GdkEventKey* event)
void BatchQueue::addEntries (const std::vector<BatchQueueEntry*>& entries, bool head, bool save)
{
{
#if PROTECT_VECTORS
MYWRITERLOCK(l, entryRW);
#endif

for (const auto entry : entries) {

Expand Down Expand Up @@ -225,9 +219,8 @@ bool BatchQueue::saveBatchQueue ()
return false;

{
#if PROTECT_VECTORS
MYREADERLOCK(l, entryRW);
#endif

if (fd.empty ())
return true;

Expand Down Expand Up @@ -264,9 +257,7 @@ bool BatchQueue::loadBatchQueue ()
if (file.is_open ()) {
// Yes, it's better to get the lock for the whole file reading,
// to update the list in one shot without any other concurrent access!
#if PROTECT_VECTORS
MYWRITERLOCK(l, entryRW);
#endif

std::string row, column;
std::vector<std::string> values;
Expand Down Expand Up @@ -398,9 +389,7 @@ int cancelItemUI (void* data)
void BatchQueue::cancelItems (const std::vector<ThumbBrowserEntryBase*>& items)
{
{
#if PROTECT_VECTORS
MYWRITERLOCK(l, entryRW);
#endif

for (const auto item : items) {

Expand Down Expand Up @@ -440,9 +429,8 @@ void BatchQueue::cancelItems (const std::vector<ThumbBrowserEntryBase*>& items)
void BatchQueue::headItems (const std::vector<ThumbBrowserEntryBase*>& items)
{
{
#if PROTECT_VECTORS
MYWRITERLOCK(l, entryRW);
#endif

for (auto item = items.rbegin(); item != items.rend(); ++item) {

const auto entry = static_cast<BatchQueueEntry*> (*item);
Expand Down Expand Up @@ -472,9 +460,7 @@ void BatchQueue::headItems (const std::vector<ThumbBrowserEntryBase*>& items)
void BatchQueue::tailItems (const std::vector<ThumbBrowserEntryBase*>& items)
{
{
#if PROTECT_VECTORS
MYWRITERLOCK(l, entryRW);
#endif

for (const auto item : items) {

Expand Down Expand Up @@ -502,10 +488,7 @@ void BatchQueue::tailItems (const std::vector<ThumbBrowserEntryBase*>& items)
void BatchQueue::selectAll ()
{
{
// TODO: Check for Linux
#if PROTECT_VECTORS
MYWRITERLOCK(l, entryRW);
#endif

lastClicked = NULL;
selected.clear ();
Expand All @@ -525,10 +508,7 @@ void BatchQueue::selectAll ()
void BatchQueue::openLastSelectedItemInEditor()
{
{
// TODO: Check for Linux
#if PROTECT_VECTORS
MYREADERLOCK(l, entryRW);
#endif

if (selected.size() > 0) {
openItemInEditor(selected.back());
Expand All @@ -550,10 +530,7 @@ void BatchQueue::startProcessing ()
{

if (!processing) {
// TODO: Check for Linux
#if PROTECT_VECTORS
MYWRITERLOCK(l, entryRW);
#endif

if (!fd.empty()) {
BatchQueueEntry* next;
Expand All @@ -575,9 +552,7 @@ void BatchQueue::startProcessing ()
processing->selected = false;
}

#if PROTECT_VECTORS
MYWRITERLOCK_RELEASE(l);
#endif

// remove button set
next->removeButtonSet ();
Expand Down Expand Up @@ -653,10 +628,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img)
bool remove_button_set = false;

{
// TODO: Check for Linux
#if PROTECT_VECTORS
MYWRITERLOCK(l, entryRW);
#endif

delete processing;
processing = NULL;
Expand Down Expand Up @@ -700,15 +672,11 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img)
// Delete all files in directory \batch when finished, just to be sure to remove zombies

// Not sure that locking is necessary, but it should be safer
// TODO: Check for Linux
#if PROTECT_VECTORS
MYREADERLOCK(l, entryRW);
#endif

if( fd.empty() ) {
#if PROTECT_VECTORS
MYREADERLOCK_RELEASE(l);
#endif

std::vector<Glib::ustring> names;
Glib::ustring batchdir = Glib::build_filename(options.rtdir, "batch");
Glib::RefPtr<Gio::File> dir = Gio::File::create_for_path (batchdir);
Expand Down Expand Up @@ -950,10 +918,7 @@ void BatchQueue::notifyListener (bool queueEmptied)
NLParams* params = new NLParams;
params->listener = listener;
{
// TODO: Check for Linux
#if PROTECT_VECTORS
MYREADERLOCK(l, entryRW);
#endif
params->qsize = fd.size();
}
params->queueEmptied = queueEmptied;
Expand Down
4 changes: 0 additions & 4 deletions rtgui/batchqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ class BatchQueue : public ThumbBrowserBase,

bool hasJobs ()
{
// not sure that this lock is necessary, but it's safer to keep it...
// TODO: Check for Linux
#if PROTECT_VECTORS
MYREADERLOCK(l, entryRW);
#endif
return (!fd.empty());
}

Expand Down
3 changes: 0 additions & 3 deletions rtgui/batchqueueentry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,7 @@ void BatchQueueEntry::_updateImage (guint8* img, int w, int h)
{

if (preh == h) {

#if PROTECT_VECTORS
MYWRITERLOCK(l, lockRW);
#endif

prew = w;
assert (preview == NULL);
Expand Down
Loading

0 comments on commit f5d5083

Please sign in to comment.