< prev index next >

src/hotspot/share/gc/shared/taskqueue.inline.hpp

Print this page




 304   } else {
 305     assert(_n == 1, "can't be zero.");
 306     return false;
 307   }
 308 }
 309 
 310 template<class T, MEMFLAGS F> bool
 311 GenericTaskQueueSet<T, F>::steal(uint queue_num, E& t) {
 312   for (uint i = 0; i < 2 * _n; i++) {
 313     TASKQUEUE_STATS_ONLY(queue(queue_num)->stats.record_steal_attempt());
 314     if (steal_best_of_2(queue_num, t)) {
 315       TASKQUEUE_STATS_ONLY(queue(queue_num)->stats.record_steal());
 316       return true;
 317     }
 318   }
 319   return false;
 320 }
 321 
 322 template <unsigned int N, MEMFLAGS F>
 323 inline typename TaskQueueSuper<N, F>::Age TaskQueueSuper<N, F>::Age::cmpxchg(const Age new_age, const Age old_age) volatile {
 324   return Atomic::cmpxchg(new_age._data, &_data, old_age._data);
 325 }
 326 
 327 template<class E, MEMFLAGS F, unsigned int N>
 328 template<class Fn>
 329 inline void GenericTaskQueue<E, F, N>::iterate(Fn fn) {
 330   uint iters = size();
 331   uint index = _bottom;
 332   for (uint i = 0; i < iters; ++i) {
 333     index = decrement_index(index);
 334     fn(const_cast<E&>(_elems[index])); // cast away volatility
 335   }
 336 }
 337 
 338 
 339 #endif // SHARE_GC_SHARED_TASKQUEUE_INLINE_HPP


 304   } else {
 305     assert(_n == 1, "can't be zero.");
 306     return false;
 307   }
 308 }
 309 
 310 template<class T, MEMFLAGS F> bool
 311 GenericTaskQueueSet<T, F>::steal(uint queue_num, E& t) {
 312   for (uint i = 0; i < 2 * _n; i++) {
 313     TASKQUEUE_STATS_ONLY(queue(queue_num)->stats.record_steal_attempt());
 314     if (steal_best_of_2(queue_num, t)) {
 315       TASKQUEUE_STATS_ONLY(queue(queue_num)->stats.record_steal());
 316       return true;
 317     }
 318   }
 319   return false;
 320 }
 321 
 322 template <unsigned int N, MEMFLAGS F>
 323 inline typename TaskQueueSuper<N, F>::Age TaskQueueSuper<N, F>::Age::cmpxchg(const Age new_age, const Age old_age) volatile {
 324   return Atomic::cmpxchg(&_data, old_age._data, new_age._data);
 325 }
 326 
 327 template<class E, MEMFLAGS F, unsigned int N>
 328 template<class Fn>
 329 inline void GenericTaskQueue<E, F, N>::iterate(Fn fn) {
 330   uint iters = size();
 331   uint index = _bottom;
 332   for (uint i = 0; i < iters; ++i) {
 333     index = decrement_index(index);
 334     fn(const_cast<E&>(_elems[index])); // cast away volatility
 335   }
 336 }
 337 
 338 
 339 #endif // SHARE_GC_SHARED_TASKQUEUE_INLINE_HPP
< prev index next >