@@ -162,9 +162,10 @@ class CgroupController: public CHeapObj<mtInternal> {
162162 static jlong limit_from_str (char * limit_str);
163163};
164164
165+ template <typename MetricType>
165166class CachedMetric : public CHeapObj <mtInternal>{
166167 private:
167- volatile jlong _metric;
168+ volatile MetricType _metric;
168169 volatile jlong _next_check_counter;
169170 public:
170171 CachedMetric () {
@@ -174,8 +175,8 @@ class CachedMetric : public CHeapObj<mtInternal>{
174175 bool should_check_metric () {
175176 return os::elapsed_counter () > _next_check_counter;
176177 }
177- jlong value () { return _metric; }
178- void set_value (jlong value, jlong timeout) {
178+ MetricType value () { return _metric; }
179+ void set_value (MetricType value, jlong timeout) {
179180 _metric = value;
180181 // Metric is unlikely to change, but we want to remain
181182 // responsive to configuration changes. A very short grace time
@@ -186,19 +187,19 @@ class CachedMetric : public CHeapObj<mtInternal>{
186187 }
187188};
188189
189- template <class T >
190+ template <class T , typename MetricType >
190191class CachingCgroupController : public CHeapObj <mtInternal> {
191192 private:
192193 T* _controller;
193- CachedMetric* _metrics_cache;
194+ CachedMetric<MetricType> * _metrics_cache;
194195
195196 public:
196197 CachingCgroupController (T* cont) {
197198 _controller = cont;
198- _metrics_cache = new CachedMetric ();
199+ _metrics_cache = new CachedMetric<MetricType> ();
199200 }
200201
201- CachedMetric* metrics_cache () { return _metrics_cache; }
202+ CachedMetric<MetricType> * metrics_cache () { return _metrics_cache; }
202203 T* controller () { return _controller; }
203204};
204205
@@ -252,7 +253,7 @@ class CgroupMemoryController: public CHeapObj<mtInternal> {
252253class CgroupSubsystem : public CHeapObj <mtInternal> {
253254 public:
254255 jlong memory_limit_in_bytes (julong upper_bound);
255- int active_processor_count ();
256+ double active_processor_count ();
256257
257258 virtual jlong pids_max () = 0;
258259 virtual jlong pids_current () = 0;
@@ -261,8 +262,8 @@ class CgroupSubsystem: public CHeapObj<mtInternal> {
261262 virtual char * cpu_cpuset_cpus () = 0;
262263 virtual char * cpu_cpuset_memory_nodes () = 0;
263264 virtual const char * container_type () = 0;
264- virtual CachingCgroupController<CgroupMemoryController>* memory_controller () = 0;
265- virtual CachingCgroupController<CgroupCpuController>* cpu_controller () = 0;
265+ virtual CachingCgroupController<CgroupMemoryController, jlong >* memory_controller () = 0;
266+ virtual CachingCgroupController<CgroupCpuController, double >* cpu_controller () = 0;
266267 virtual CgroupCpuacctController* cpuacct_controller () = 0;
267268
268269 int cpu_quota ();
0 commit comments