< prev index next >

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

Print this page




 298 // monitor and execution of each worker as it checks for work
 299 // is serialized via the same monitor.  The "needs_more_workers()"
 300 // call is serialized and additionally the calculation for the
 301 // "part" (effectively the worker id for executing the task) is
 302 // serialized to give each worker a unique "part".  Workers that
 303 // are not needed for this tasks (i.e., "_active_workers" have
 304 // been started before it, continue to wait for work.
 305 
 306 class FlexibleWorkGang: public WorkGang {
 307   // The currently active workers in this gang.
 308   // This is a number that is dynamically adjusted
 309   // and checked in the run_task() method at each invocation.
 310   // As described above _active_workers determines the number
 311   // of threads started on a task.  It must also be used to
 312   // determine completion.
 313 
 314  protected:
 315   uint _active_workers;
 316  public:
 317   // Constructor and destructor.
 318   // Initialize active_workers to a minimum value.  Setting it to
 319   // the parameter "workers" will initialize it to a maximum
 320   // value which is not desirable.
 321   FlexibleWorkGang(const char* name, uint workers,
 322                    bool are_GC_task_threads,
 323                    bool  are_ConcurrentGC_threads) :
 324     WorkGang(name, workers, are_GC_task_threads, are_ConcurrentGC_threads),
 325     _active_workers(UseDynamicNumberOfGCThreads ? 1U : ParallelGCThreads) {}
 326   // Accessors for fields

 327   virtual uint active_workers() const { return _active_workers; }
 328   void set_active_workers(uint v) {
 329     assert(v <= _total_workers,
 330            "Trying to set more workers active than there are");
 331     _active_workers = MIN2(v, _total_workers);
 332     assert(v != 0, "Trying to set active workers to 0");
 333     _active_workers = MAX2(1U, _active_workers);
 334     assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
 335            "Unless dynamic should use total workers");
 336   }
 337   virtual void run_task(AbstractGangTask* task);
 338   virtual bool needs_more_workers() const {
 339     return _started_workers < _active_workers;
 340   }
 341 };
 342 
 343 // A class that acts as a synchronisation barrier. Workers enter
 344 // the barrier and must wait until all other workers have entered
 345 // before any of them may leave.
 346 




 298 // monitor and execution of each worker as it checks for work
 299 // is serialized via the same monitor.  The "needs_more_workers()"
 300 // call is serialized and additionally the calculation for the
 301 // "part" (effectively the worker id for executing the task) is
 302 // serialized to give each worker a unique "part".  Workers that
 303 // are not needed for this tasks (i.e., "_active_workers" have
 304 // been started before it, continue to wait for work.
 305 
 306 class FlexibleWorkGang: public WorkGang {
 307   // The currently active workers in this gang.
 308   // This is a number that is dynamically adjusted
 309   // and checked in the run_task() method at each invocation.
 310   // As described above _active_workers determines the number
 311   // of threads started on a task.  It must also be used to
 312   // determine completion.
 313 
 314  protected:
 315   uint _active_workers;
 316  public:
 317   // Constructor and destructor.



 318   FlexibleWorkGang(const char* name, uint workers,
 319                    bool are_GC_task_threads,
 320                    bool  are_ConcurrentGC_threads) :
 321     WorkGang(name, workers, are_GC_task_threads, are_ConcurrentGC_threads),
 322     _active_workers(UseDynamicNumberOfGCThreads ? 1U : workers) {}
 323 
 324   // Accessors for fields.
 325   virtual uint active_workers() const { return _active_workers; }
 326   void set_active_workers(uint v) {
 327     assert(v <= _total_workers,
 328            "Trying to set more workers active than there are");
 329     _active_workers = MIN2(v, _total_workers);
 330     assert(v != 0, "Trying to set active workers to 0");
 331     _active_workers = MAX2(1U, _active_workers);
 332     assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
 333            "Unless dynamic should use total workers");
 334   }
 335   virtual void run_task(AbstractGangTask* task);
 336   virtual bool needs_more_workers() const {
 337     return _started_workers < _active_workers;
 338   }
 339 };
 340 
 341 // A class that acts as a synchronisation barrier. Workers enter
 342 // the barrier and must wait until all other workers have entered
 343 // before any of them may leave.
 344 


< prev index next >