comparison src/share/vm/utilities/workgroup.hpp @ 17949:487f09bf44e0

8040803: G1: Concurrent mark hangs when mark stack overflows Reviewed-by: brutisso, ehelin
author pliden
date Wed, 14 May 2014 13:32:44 +0200
parents f9be75d21404
children
comparison
equal deleted inserted replaced
17948:e4d318eea75a 17949:487f09bf44e0
357 // before any of them may leave. 357 // before any of them may leave.
358 358
359 class WorkGangBarrierSync : public StackObj { 359 class WorkGangBarrierSync : public StackObj {
360 protected: 360 protected:
361 Monitor _monitor; 361 Monitor _monitor;
362 uint _n_workers; 362 uint _n_workers;
363 uint _n_completed; 363 uint _n_completed;
364 bool _should_reset; 364 bool _should_reset;
365 bool _aborted;
365 366
366 Monitor* monitor() { return &_monitor; } 367 Monitor* monitor() { return &_monitor; }
367 uint n_workers() { return _n_workers; } 368 uint n_workers() { return _n_workers; }
368 uint n_completed() { return _n_completed; } 369 uint n_completed() { return _n_completed; }
369 bool should_reset() { return _should_reset; } 370 bool should_reset() { return _should_reset; }
371 bool aborted() { return _aborted; }
370 372
371 void zero_completed() { _n_completed = 0; } 373 void zero_completed() { _n_completed = 0; }
372 void inc_completed() { _n_completed++; } 374 void inc_completed() { _n_completed++; }
373 375 void set_aborted() { _aborted = true; }
374 void set_should_reset(bool v) { _should_reset = v; } 376 void set_should_reset(bool v) { _should_reset = v; }
375 377
376 public: 378 public:
377 WorkGangBarrierSync(); 379 WorkGangBarrierSync();
378 WorkGangBarrierSync(uint n_workers, const char* name); 380 WorkGangBarrierSync(uint n_workers, const char* name);
381 // Must be called before any of the workers start running. 383 // Must be called before any of the workers start running.
382 void set_n_workers(uint n_workers); 384 void set_n_workers(uint n_workers);
383 385
384 // Enter the barrier. A worker that enters the barrier will 386 // Enter the barrier. A worker that enters the barrier will
385 // not be allowed to leave until all other threads have 387 // not be allowed to leave until all other threads have
386 // also entered the barrier. 388 // also entered the barrier or the barrier is aborted.
387 void enter(); 389 // Returns false if the barrier was aborted.
390 bool enter();
391
392 // Aborts the barrier and wakes up any threads waiting for
393 // the barrier to complete. The barrier will remain in the
394 // aborted state until the next call to set_n_workers().
395 void abort();
388 }; 396 };
389 397
390 // A class to manage claiming of subtasks within a group of tasks. The 398 // A class to manage claiming of subtasks within a group of tasks. The
391 // subtasks will be identified by integer indices, usually elements of an 399 // subtasks will be identified by integer indices, usually elements of an
392 // enumeration type. 400 // enumeration type.