255 }
256 GCTask* dequeue(uint affinity) {
257 guarantee(own_lock(), "don't own the lock");
258 return unsynchronized_queue()->dequeue(affinity);
259 }
260 uint length() const {
261 guarantee(own_lock(), "don't own the lock");
262 return unsynchronized_queue()->length();
263 }
264 // For guarantees.
265 bool own_lock() const {
266 return lock()->owned_by_self();
267 }
268 protected:
269 // Constructor. Clients use factory, but there might be subclasses.
270 SynchronizedGCTaskQueue(GCTaskQueue* queue, Monitor * lock);
271 // Destructor. Not virtual because no virtuals.
272 ~SynchronizedGCTaskQueue();
273 };
274
275 class WaitHelper VALUE_OBJ_CLASS_SPEC {
276 private:
277 Monitor* _monitor;
278 volatile bool _should_wait;
279 public:
280 WaitHelper();
281 ~WaitHelper();
282 void wait_for(bool reset);
283 void notify();
284 void set_should_wait(bool value) {
285 _should_wait = value;
286 }
287
288 Monitor* monitor() const {
289 return _monitor;
290 }
291 bool should_wait() const {
292 return _should_wait;
293 }
294 void release_monitor();
295 };
|
255 }
256 GCTask* dequeue(uint affinity) {
257 guarantee(own_lock(), "don't own the lock");
258 return unsynchronized_queue()->dequeue(affinity);
259 }
260 uint length() const {
261 guarantee(own_lock(), "don't own the lock");
262 return unsynchronized_queue()->length();
263 }
264 // For guarantees.
265 bool own_lock() const {
266 return lock()->owned_by_self();
267 }
268 protected:
269 // Constructor. Clients use factory, but there might be subclasses.
270 SynchronizedGCTaskQueue(GCTaskQueue* queue, Monitor * lock);
271 // Destructor. Not virtual because no virtuals.
272 ~SynchronizedGCTaskQueue();
273 };
274
275 class WaitHelper {
276 private:
277 Monitor* _monitor;
278 volatile bool _should_wait;
279 public:
280 WaitHelper();
281 ~WaitHelper();
282 void wait_for(bool reset);
283 void notify();
284 void set_should_wait(bool value) {
285 _should_wait = value;
286 }
287
288 Monitor* monitor() const {
289 return _monitor;
290 }
291 bool should_wait() const {
292 return _should_wait;
293 }
294 void release_monitor();
295 };
|