115
116 public:
117 AbstractWorkGang(const char* name, uint workers, bool are_GC_task_threads, bool are_ConcurrentGC_threads) :
118 _name(name),
119 _total_workers(workers),
120 _active_workers(UseDynamicNumberOfGCThreads ? 1U : workers),
121 _are_GC_task_threads(are_GC_task_threads),
122 _are_ConcurrentGC_threads(are_ConcurrentGC_threads)
123 { }
124
125 // Initialize workers in the gang. Return true if initialization succeeded.
126 bool initialize_workers();
127
128 bool are_GC_task_threads() const { return _are_GC_task_threads; }
129 bool are_ConcurrentGC_threads() const { return _are_ConcurrentGC_threads; }
130
131 uint total_workers() const { return _total_workers; }
132
133 virtual uint active_workers() const {
134 assert(_active_workers <= _total_workers,
135 err_msg("_active_workers: %u > _total_workers: %u", _active_workers, _total_workers));
136 assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
137 "Unless dynamic should use total workers");
138 return _active_workers;
139 }
140 void set_active_workers(uint v) {
141 assert(v <= _total_workers,
142 "Trying to set more workers active than there are");
143 _active_workers = MIN2(v, _total_workers);
144 assert(v != 0, "Trying to set active workers to 0");
145 _active_workers = MAX2(1U, _active_workers);
146 assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
147 "Unless dynamic should use total workers");
148 }
149
150 // Return the Ith worker.
151 AbstractGangWorker* worker(uint i) const;
152
153 void threads_do(ThreadClosure* tc) const;
154
155 // Debugging.
|
115
116 public:
117 AbstractWorkGang(const char* name, uint workers, bool are_GC_task_threads, bool are_ConcurrentGC_threads) :
118 _name(name),
119 _total_workers(workers),
120 _active_workers(UseDynamicNumberOfGCThreads ? 1U : workers),
121 _are_GC_task_threads(are_GC_task_threads),
122 _are_ConcurrentGC_threads(are_ConcurrentGC_threads)
123 { }
124
125 // Initialize workers in the gang. Return true if initialization succeeded.
126 bool initialize_workers();
127
128 bool are_GC_task_threads() const { return _are_GC_task_threads; }
129 bool are_ConcurrentGC_threads() const { return _are_ConcurrentGC_threads; }
130
131 uint total_workers() const { return _total_workers; }
132
133 virtual uint active_workers() const {
134 assert(_active_workers <= _total_workers,
135 "_active_workers: %u > _total_workers: %u", _active_workers, _total_workers);
136 assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
137 "Unless dynamic should use total workers");
138 return _active_workers;
139 }
140 void set_active_workers(uint v) {
141 assert(v <= _total_workers,
142 "Trying to set more workers active than there are");
143 _active_workers = MIN2(v, _total_workers);
144 assert(v != 0, "Trying to set active workers to 0");
145 _active_workers = MAX2(1U, _active_workers);
146 assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
147 "Unless dynamic should use total workers");
148 }
149
150 // Return the Ith worker.
151 AbstractGangWorker* worker(uint i) const;
152
153 void threads_do(ThreadClosure* tc) const;
154
155 // Debugging.
|