MCPcopy Create free account
hub / github.com/aseprite/laf / canWriteLockFromRead

Method canWriteLockFromRead

base/rw_lock.cpp:37–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37bool RWLock::canWriteLockFromRead() const
38{
39 const std::lock_guard lock(m_mutex);
40
41 // If this thread already have a writer lock, we can upgrade any
42 // reader lock to writer in the same thread (re-entrant locks).
43 if (m_write_lock && m_write_thread == std::this_thread::get_id()) {
44 return true;
45 }
46 // If only we are reading (one lock) and nobody is writing, we can
47 // lock for writing..
48 return (m_read_locks == 1 && !m_write_lock);
49}
50
51RWLock::LockResult RWLock::lock(LockType lockType, int timeout)
52{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected