comparison Implab/Parallels/MTQueue.cs @ 24:ee04e1fa78da

fixed dispatch pool race condition
author cin
date Thu, 14 Nov 2013 01:15:07 +0400
parents e3935fdf59a2
children 1714fd8678ef
comparison
equal deleted inserted replaced
23:f0568ff069a5 24:ee04e1fa78da
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 the 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 a ace condition 47 // this is a race condition
48 if (m_last == null) 48 if (m_last == null)
49 // the queue is empty 49 // the queue is empty
50 return false; 50 return false;
51 // tail has been changed, than we need to restart 51 // tail has been changed, than we need to restart
52 continue; 52 continue;