| 35 | } |
| 36 | |
| 37 | bool 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 | |
| 51 | RWLock::LockResult RWLock::lock(LockType lockType, int timeout) |
| 52 | { |
nothing calls this directly
no outgoing calls
no test coverage detected