242 } else {
243 assert(_n == 1, "can't be zero.");
244 return false;
245 }
246 }
247
248 template<class T, MEMFLAGS F> bool
249 GenericTaskQueueSet<T, F>::steal(uint queue_num, int* seed, E& t) {
250 for (uint i = 0; i < 2 * _n; i++) {
251 if (steal_best_of_2(queue_num, seed, t)) {
252 TASKQUEUE_STATS_ONLY(queue(queue_num)->stats.record_steal(true));
253 return true;
254 }
255 }
256 TASKQUEUE_STATS_ONLY(queue(queue_num)->stats.record_steal(false));
257 return false;
258 }
259
260 template <unsigned int N, MEMFLAGS F>
261 inline typename TaskQueueSuper<N, F>::Age TaskQueueSuper<N, F>::Age::cmpxchg(const Age new_age, const Age old_age) volatile {
262 return (size_t) Atomic::cmpxchg(new_age._data, &_data, old_age._data);
263 }
264
265 template<class E, MEMFLAGS F, unsigned int N>
266 template<class Fn>
267 inline void GenericTaskQueue<E, F, N>::iterate(Fn fn) {
268 uint iters = size();
269 uint index = _bottom;
270 for (uint i = 0; i < iters; ++i) {
271 index = decrement_index(index);
272 fn(const_cast<E&>(_elems[index])); // cast away volatility
273 }
274 }
275
276
277 #endif // SHARE_VM_GC_SHARED_TASKQUEUE_INLINE_HPP
|
242 } else {
243 assert(_n == 1, "can't be zero.");
244 return false;
245 }
246 }
247
248 template<class T, MEMFLAGS F> bool
249 GenericTaskQueueSet<T, F>::steal(uint queue_num, int* seed, E& t) {
250 for (uint i = 0; i < 2 * _n; i++) {
251 if (steal_best_of_2(queue_num, seed, t)) {
252 TASKQUEUE_STATS_ONLY(queue(queue_num)->stats.record_steal(true));
253 return true;
254 }
255 }
256 TASKQUEUE_STATS_ONLY(queue(queue_num)->stats.record_steal(false));
257 return false;
258 }
259
260 template <unsigned int N, MEMFLAGS F>
261 inline typename TaskQueueSuper<N, F>::Age TaskQueueSuper<N, F>::Age::cmpxchg(const Age new_age, const Age old_age) volatile {
262 return Atomic::cmpxchg(new_age._data, &_data, old_age._data);
263 }
264
265 template<class E, MEMFLAGS F, unsigned int N>
266 template<class Fn>
267 inline void GenericTaskQueue<E, F, N>::iterate(Fn fn) {
268 uint iters = size();
269 uint index = _bottom;
270 for (uint i = 0; i < iters; ++i) {
271 index = decrement_index(index);
272 fn(const_cast<E&>(_elems[index])); // cast away volatility
273 }
274 }
275
276
277 #endif // SHARE_VM_GC_SHARED_TASKQUEUE_INLINE_HPP
|