< prev index next >

src/share/vm/gc/shared/workgroup.hpp

Print this page
rev 11970 : imported patch workgroup_volatiles


 296   // Must be called before any of the workers start running.
 297   void set_n_workers(uint n_workers);
 298 
 299   // Enter the barrier. A worker that enters the barrier will
 300   // not be allowed to leave until all other threads have
 301   // also entered the barrier or the barrier is aborted.
 302   // Returns false if the barrier was aborted.
 303   bool enter();
 304 
 305   // Aborts the barrier and wakes up any threads waiting for
 306   // the barrier to complete. The barrier will remain in the
 307   // aborted state until the next call to set_n_workers().
 308   void abort();
 309 };
 310 
 311 // A class to manage claiming of subtasks within a group of tasks.  The
 312 // subtasks will be identified by integer indices, usually elements of an
 313 // enumeration type.
 314 
 315 class SubTasksDone: public CHeapObj<mtInternal> {
 316   uint* _tasks;
 317   uint _n_tasks;
 318   uint _threads_completed;
 319 #ifdef ASSERT
 320   volatile uint _claimed;
 321 #endif
 322 
 323   // Set all tasks to unclaimed.
 324   void clear();
 325 
 326 public:
 327   // Initializes "this" to a state in which there are "n" tasks to be
 328   // processed, none of the which are originally claimed.  The number of
 329   // threads doing the tasks is initialized 1.
 330   SubTasksDone(uint n);
 331 
 332   // True iff the object is in a valid state.
 333   bool valid();
 334 
 335   // Returns "false" if the task "t" is unclaimed, and ensures that task is
 336   // claimed.  The task "t" is required to be within the range of "this".
 337   bool is_task_claimed(uint t);
 338 


 341   // must execute this.  (When the last thread does so, the task array is
 342   // cleared.)
 343   //
 344   // n_threads - Number of threads executing the sub-tasks.
 345   void all_tasks_completed(uint n_threads);
 346 
 347   // Destructor.
 348   ~SubTasksDone();
 349 };
 350 
 351 // As above, but for sequential tasks, i.e. instead of claiming
 352 // sub-tasks from a set (possibly an enumeration), claim sub-tasks
 353 // in sequential order. This is ideal for claiming dynamically
 354 // partitioned tasks (like striding in the parallel remembered
 355 // set scanning). Note that unlike the above class this is
 356 // a stack object - is there any reason for it not to be?
 357 
 358 class SequentialSubTasksDone : public StackObj {
 359 protected:
 360   uint _n_tasks;     // Total number of tasks available.
 361   uint _n_claimed;   // Number of tasks claimed.
 362   // _n_threads is used to determine when a sub task is done.
 363   // See comments on SubTasksDone::_n_threads
 364   uint _n_threads;   // Total number of parallel threads.
 365   uint _n_completed; // Number of completed threads.
 366 
 367   void clear();
 368 
 369 public:
 370   SequentialSubTasksDone() {
 371     clear();
 372   }
 373   ~SequentialSubTasksDone() {}
 374 
 375   // True iff the object is in a valid state.
 376   bool valid();
 377 
 378   // number of tasks
 379   uint n_tasks() const { return _n_tasks; }
 380 
 381   // Get/set the number of parallel threads doing the tasks to t.
 382   // Should be called before the task starts but it is safe
 383   // to call this once a task is running provided that all
 384   // threads agree on the number of threads.
 385   uint n_threads() { return _n_threads; }




 296   // Must be called before any of the workers start running.
 297   void set_n_workers(uint n_workers);
 298 
 299   // Enter the barrier. A worker that enters the barrier will
 300   // not be allowed to leave until all other threads have
 301   // also entered the barrier or the barrier is aborted.
 302   // Returns false if the barrier was aborted.
 303   bool enter();
 304 
 305   // Aborts the barrier and wakes up any threads waiting for
 306   // the barrier to complete. The barrier will remain in the
 307   // aborted state until the next call to set_n_workers().
 308   void abort();
 309 };
 310 
 311 // A class to manage claiming of subtasks within a group of tasks.  The
 312 // subtasks will be identified by integer indices, usually elements of an
 313 // enumeration type.
 314 
 315 class SubTasksDone: public CHeapObj<mtInternal> {
 316   volatile uint* _tasks;
 317   uint _n_tasks;
 318   volatile uint _threads_completed;
 319 #ifdef ASSERT
 320   volatile uint _claimed;
 321 #endif
 322 
 323   // Set all tasks to unclaimed.
 324   void clear();
 325 
 326 public:
 327   // Initializes "this" to a state in which there are "n" tasks to be
 328   // processed, none of the which are originally claimed.  The number of
 329   // threads doing the tasks is initialized 1.
 330   SubTasksDone(uint n);
 331 
 332   // True iff the object is in a valid state.
 333   bool valid();
 334 
 335   // Returns "false" if the task "t" is unclaimed, and ensures that task is
 336   // claimed.  The task "t" is required to be within the range of "this".
 337   bool is_task_claimed(uint t);
 338 


 341   // must execute this.  (When the last thread does so, the task array is
 342   // cleared.)
 343   //
 344   // n_threads - Number of threads executing the sub-tasks.
 345   void all_tasks_completed(uint n_threads);
 346 
 347   // Destructor.
 348   ~SubTasksDone();
 349 };
 350 
 351 // As above, but for sequential tasks, i.e. instead of claiming
 352 // sub-tasks from a set (possibly an enumeration), claim sub-tasks
 353 // in sequential order. This is ideal for claiming dynamically
 354 // partitioned tasks (like striding in the parallel remembered
 355 // set scanning). Note that unlike the above class this is
 356 // a stack object - is there any reason for it not to be?
 357 
 358 class SequentialSubTasksDone : public StackObj {
 359 protected:
 360   uint _n_tasks;     // Total number of tasks available.
 361   volatile uint _n_claimed;   // Number of tasks claimed.
 362   // _n_threads is used to determine when a sub task is done.
 363   // See comments on SubTasksDone::_n_threads
 364   uint _n_threads;   // Total number of parallel threads.
 365   volatile uint _n_completed; // Number of completed threads.
 366 
 367   void clear();
 368 
 369 public:
 370   SequentialSubTasksDone() {
 371     clear();
 372   }
 373   ~SequentialSubTasksDone() {}
 374 
 375   // True iff the object is in a valid state.
 376   bool valid();
 377 
 378   // number of tasks
 379   uint n_tasks() const { return _n_tasks; }
 380 
 381   // Get/set the number of parallel threads doing the tasks to t.
 382   // Should be called before the task starts but it is safe
 383   // to call this once a task is running provided that all
 384   // threads agree on the number of threads.
 385   uint n_threads() { return _n_threads; }


< prev index next >