##// END OF EJS Templates
fixed regression: race condition in Promise...
cin -
r160:5802131432e4 v2
parent child
Show More
@@ -160,8 +160,12 namespace Implab {
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
@@ -11,10 +11,8
11 }
11 }
12
12
13 public CDFADefinition Optimize() {
13 public CDFADefinition Optimize() {
14 var optimized = new CDFADefinition(new CharAlphabet());
14
15
15 return (CDFADefinition)Optimize(alphabet => new CDFADefinition((CharAlphabet)alphabet), m_alphabet, new CharAlphabet());
16 Optimize(optimized, m_alphabet, optimized.Alphabet);
17 return optimized;
18 }
16 }
19
17
20 public void PrintDFA() {
18 public void PrintDFA() {
@@ -66,8 +66,8 namespace Implab.Parsing {
66 m_states[s1].transitions[symbol] = s2;
66 m_states[s1].transitions[symbol] = s2;
67 }
67 }
68
68
69 public void Optimize<TA>(IDFADefinition minimalDFA,IAlphabet<TA> sourceAlphabet, IAlphabet<TA> minimalAlphabet) {
69 protected IDFADefinition Optimize<TA>(Func<IAlphabet<TA>, IDFADefinition> dfaFactory,IAlphabet<TA> sourceAlphabet, IAlphabet<TA> minimalAlphabet) {
70 Safe.ArgumentNotNull(minimalDFA, "minimalDFA");
70 Safe.ArgumentNotNull(dfaFactory, "dfaFactory");
71 Safe.ArgumentNotNull(minimalAlphabet, "minimalAlphabet");
71 Safe.ArgumentNotNull(minimalAlphabet, "minimalAlphabet");
72
72
73 var setComparer = new CustomEqualityComparer<HashSet<int>>(
73 var setComparer = new CustomEqualityComparer<HashSet<int>>(
@@ -211,6 +211,8 namespace Implab.Parsing {
211
211
212 // построение автомата
212 // построение автомата
213
213
214 var minimalDFA = dfaFactory(minimalAlphabet);
215
214 var states = new int[ optimalMap.Length ];
216 var states = new int[ optimalMap.Length ];
215 states[0] = UNREACHEBLE_STATE;
217 states[0] = UNREACHEBLE_STATE;
216
218
@@ -237,6 +239,7 namespace Implab.Parsing {
237 }
239 }
238 }
240 }
239
241
242 return minimalDFA;
240 }
243 }
241
244
242 public void PrintDFA<TA>(IAlphabet<TA> alphabet) {
245 public void PrintDFA<TA>(IAlphabet<TA> alphabet) {
@@ -18,10 +18,8 namespace Implab.Parsing {
18 }
18 }
19
19
20 public EDFADefinition<T> Optimize() {
20 public EDFADefinition<T> Optimize() {
21 var optimized = new EDFADefinition<T>(new EnumAlphabet<T>());
21
22 Optimize(optimized, m_alphabet, optimized.Alphabet);
22 return (EDFADefinition<T>)Optimize(alphabet => new EDFADefinition<T>((EnumAlphabet<T>)alphabet), m_alphabet, new EnumAlphabet<T>());
23
24 return optimized;
25 }
23 }
26
24
27 public void PrintDFA() {
25 public void PrintDFA() {
General Comments 0
You need to be logged in to leave comments. Login now