mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 12:39:57 +00:00
Add DEBUG_DOCUMENT_LOCKS to avoid logging doc locks
This commit is contained in:
parent
7fb984b18d
commit
a4277e8175
@ -8,6 +8,10 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
// Uncomment this line in case that you want TRACE() lock/unlock
|
||||
// operations.
|
||||
//#define DEBUG_DOCUMENT_LOCKS
|
||||
|
||||
#include "app/document.h"
|
||||
|
||||
#include "app/app.h"
|
||||
@ -459,7 +463,10 @@ bool Document::lock(LockType lockType, int timeout)
|
||||
if (m_read_locks == 0 && !m_write_lock) {
|
||||
// We can start writting the sprite...
|
||||
m_write_lock = true;
|
||||
|
||||
#ifdef DEBUG_DOCUMENT_LOCKS
|
||||
TRACE("Document::lock: Locked <%d> to write\n", id());
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
@ -471,15 +478,21 @@ bool Document::lock(LockType lockType, int timeout)
|
||||
int delay = MIN(100, timeout);
|
||||
timeout -= delay;
|
||||
|
||||
#ifdef DEBUG_DOCUMENT_LOCKS
|
||||
TRACE("Document::lock: wait 100 msecs for <%d>\n", id());
|
||||
#endif
|
||||
|
||||
base::this_thread::sleep_for(double(delay) / 1000.0);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DOCUMENT_LOCKS
|
||||
TRACE("Document::lock: Cannot lock <%d> to %s (has %d read locks and %d write locks)\n",
|
||||
id(), (lockType == ReadLock ? "read": "write"), m_read_locks, m_write_lock);
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -493,7 +506,11 @@ bool Document::lockToWrite(int timeout)
|
||||
ASSERT(!m_write_lock);
|
||||
m_read_locks = 0;
|
||||
m_write_lock = true;
|
||||
|
||||
#ifdef DEBUG_DOCUMENT_LOCKS
|
||||
TRACE("Document::lockToWrite: Locked <%d> to write\n", id());
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -502,15 +519,21 @@ bool Document::lockToWrite(int timeout)
|
||||
int delay = MIN(100, timeout);
|
||||
timeout -= delay;
|
||||
|
||||
#ifdef DEBUG_DOCUMENT_LOCKS
|
||||
TRACE("Document::lockToWrite: wait 100 msecs for <%d>\n", id());
|
||||
#endif
|
||||
|
||||
base::this_thread::sleep_for(double(delay) / 1000.0);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DOCUMENT_LOCKS
|
||||
TRACE("Document::lockToWrite: Cannot lock <%d> to write (has %d read locks and %d write locks)\n",
|
||||
id(), m_read_locks, m_write_lock);
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user