Mercurial > pub > ImplabNet
comparison Implab/Parallels/SharedLock.cs @ 130:671f60cd0250 v2
fixed Resove method bug when calling it on already cancelled promise
author | cin |
---|---|
date | Fri, 30 Jan 2015 17:07:17 +0300 |
parents | 471f596b2603 |
children | e9e7940c7d98 |
comparison
equal
deleted
inserted
replaced
129:471f596b2603 | 130:671f60cd0250 |
---|---|
15 lock (m_lock) { | 15 lock (m_lock) { |
16 if (m_locks > 0 && !Monitor.Wait(m_lock, timeout)) | 16 if (m_locks > 0 && !Monitor.Wait(m_lock, timeout)) |
17 return false; | 17 return false; |
18 m_exclusive = true; | 18 m_exclusive = true; |
19 m_locks = 1; | 19 m_locks = 1; |
20 return true; | |
20 } | 21 } |
21 } | 22 } |
22 | 23 |
23 public void LockExclusive() { | 24 public void LockExclusive() { |
24 LockExclusive(-1); | 25 LockExclusive(-1); |
29 if (!m_exclusive) { | 30 if (!m_exclusive) { |
30 m_locks++; | 31 m_locks++; |
31 return true; | 32 return true; |
32 } | 33 } |
33 | 34 |
34 if (m_lock == 0) { | 35 if (m_locks == 0) { |
35 m_exclusive = false; | 36 m_exclusive = false; |
36 m_locks = 1; | 37 m_locks = 1; |
37 return true; | 38 return true; |
38 } | 39 } |
39 | 40 |