Mercurial > pub > ImplabNet
comparison Implab/Parallels/MTQueue.cs @ 23:f0568ff069a5
Слияние с promises
author | cin |
---|---|
date | Wed, 13 Nov 2013 14:03:20 +0400 |
parents | e3935fdf59a2 |
children | ee04e1fa78da |
comparison
equal
deleted
inserted
replaced
18:0c924dff5498 | 23:f0568ff069a5 |
---|---|
40 if (first == null) | 40 if (first == null) |
41 return false; | 41 return false; |
42 next = first.next; | 42 next = first.next; |
43 if (next == null) { | 43 if (next == null) { |
44 // this is the last element, | 44 // this is the last element, |
45 // then try to update tail | 45 // then try to update the tail |
46 if (first != Interlocked.CompareExchange(ref m_last, null, first)) { | 46 if (first != Interlocked.CompareExchange(ref m_last, null, first)) { |
47 // this is inconsistent situation which means that the queue is empty | 47 // this is a ace condition |
48 if (m_last == null) | 48 if (m_last == null) |
49 // the queue is empty | |
49 return false; | 50 return false; |
50 // tail has been changed, that means that we need to restart | 51 // tail has been changed, than we need to restart |
51 continue; | 52 continue; |
52 } | 53 } |
53 | 54 |
54 // tail succesfully updated and first.next will never be changed | 55 // tail succesfully updated and first.next will never be changed |
55 // other readers will fail due to inconsistency m_last != m_fist, but m_first.next == null | 56 // other readers will fail due to inconsistency m_last != m_fist, but m_first.next == null |