mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-30 15:22:41 +00:00
8366035: Simplify CPUTimeCounters::publish_gc_total_cpu_time
Reviewed-by: ayang, kbarrett
This commit is contained in:
parent
68abf76e90
commit
2ae3ea2ad9
@ -75,15 +75,9 @@ void CPUTimeCounters::inc_gc_total_cpu_time(jlong diff) {
|
||||
|
||||
void CPUTimeCounters::publish_gc_total_cpu_time() {
|
||||
CPUTimeCounters* instance = CPUTimeCounters::get_instance();
|
||||
// Ensure that we are only incrementing atomically by using Atomic::cmpxchg
|
||||
// to set the value to zero after we obtain the new CPU time difference.
|
||||
jlong old_value;
|
||||
jlong fetched_value = Atomic::load(&(instance->_gc_total_cpu_time_diff));
|
||||
// Atomically fetch the current _gc_total_cpu_time_diff and reset it to zero.
|
||||
jlong new_value = 0;
|
||||
do {
|
||||
old_value = fetched_value;
|
||||
fetched_value = Atomic::cmpxchg(&(instance->_gc_total_cpu_time_diff), old_value, new_value);
|
||||
} while (old_value != fetched_value);
|
||||
jlong fetched_value = Atomic::xchg(&(instance->_gc_total_cpu_time_diff), new_value);
|
||||
get_counter(CPUTimeGroups::CPUTimeType::gc_total)->inc(fetched_value);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user