141 FORCEINLINE CYapfSegmentCostCacheGlobalT() : m_global_cache(stGetGlobalCache()) {}; |
144 FORCEINLINE CYapfSegmentCostCacheGlobalT() : m_global_cache(stGetGlobalCache()) {}; |
142 |
145 |
143 /// to access inherited path finder |
146 /// to access inherited path finder |
144 FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);} |
147 FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);} |
145 |
148 |
146 FORCEINLINE static Cache*& stGlobalCachePtr() {static Cache* pC = NULL; return pC;} |
|
147 |
|
148 FORCEINLINE static Cache& stGetGlobalCache() |
149 FORCEINLINE static Cache& stGetGlobalCache() |
149 { |
150 { |
150 static int last_rail_change_counter = 0; |
151 static int last_rail_change_counter = 0; |
151 static Date last_date = 0; |
152 static Date last_date = 0; |
|
153 static Cache C; |
152 |
154 |
153 // some statistics |
155 // some statistics |
154 if (last_date != _date) { |
156 if (last_date != _date) { |
155 last_date = _date; |
157 last_date = _date; |
156 DEBUG(yapf, 1) ("pf time today:%5d ms", _total_pf_time_us / 1000); |
158 DEBUG(yapf, 1) ("pf time today:%5d ms", _total_pf_time_us / 1000); |
157 _total_pf_time_us = 0; |
159 _total_pf_time_us = 0; |
158 } |
160 } |
159 |
161 |
160 Cache*& pC = stGlobalCachePtr(); |
|
161 |
|
162 // delete the cache sometimes... |
162 // delete the cache sometimes... |
163 if (pC != NULL && last_rail_change_counter != Cache::s_rail_change_counter) { |
163 if (last_rail_change_counter != Cache::s_rail_change_counter) { |
164 last_rail_change_counter = Cache::s_rail_change_counter; |
164 last_rail_change_counter = Cache::s_rail_change_counter; |
165 delete pC; |
165 C.Flush(); |
166 pC = NULL; |
|
167 } |
166 } |
168 |
167 return C; |
169 if (pC == NULL) |
|
170 pC = new Cache(); |
|
171 return *pC; |
|
172 } |
168 } |
173 |
169 |
174 public: |
170 public: |
175 /** Called by YAPF to attach cached or local segment cost data to the given node. |
171 /** Called by YAPF to attach cached or local segment cost data to the given node. |
176 * @return true if globally cached data were used or false if local data was used */ |
172 * @return true if globally cached data were used or false if local data was used */ |