Mercurial > pub > ImplabNet
comparison Implab/AbstractEvent.cs @ 160:5802131432e4 v2
fixed regression: race condition in Promise
DFA refactoring
author | cin |
---|---|
date | Thu, 18 Feb 2016 19:38:54 +0300 |
parents | 97fbbf816844 |
children | 822aab37b107 |
comparison
equal
deleted
inserted
replaced
159:5558e43c79bb | 160:5802131432e4 |
---|---|
158 } else { | 158 } else { |
159 var slot = Interlocked.Increment(ref m_handlersCount) - 1; | 159 var slot = Interlocked.Increment(ref m_handlersCount) - 1; |
160 | 160 |
161 if (slot < RESERVED_HANDLERS_COUNT) { | 161 if (slot < RESERVED_HANDLERS_COUNT) { |
162 | 162 |
163 if (slot == 0) | 163 if (slot == 0) { |
164 Interlocked.CompareExchange(ref m_handlers, new THandler[RESERVED_HANDLERS_COUNT], null); | 164 m_handlers = new THandler[RESERVED_HANDLERS_COUNT]; |
165 } else { | |
166 while (m_handlers == null) | |
167 Thread.MemoryBarrier(); | |
168 } | |
165 | 169 |
166 m_handlers[slot] = handler; | 170 m_handlers[slot] = handler; |
167 | 171 |
168 while (slot != Interlocked.CompareExchange(ref m_handlersCommited, slot + 1, slot)) { | 172 while (slot != Interlocked.CompareExchange(ref m_handlersCommited, slot + 1, slot)) { |
169 } | 173 } |