waste less cpu cycles when incrementing local counter

This commit is contained in:
2024-07-10 18:24:14 +02:00
parent aaf78401a5
commit 41674ad4cf
2 changed files with 4 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
package com.usatiuk.dhfs.objects.repository;
import lombok.Getter;
import java.io.Serial;
import java.io.Serializable;
import java.util.concurrent.locks.ReadWriteLock;
@@ -9,6 +11,7 @@ public class PersistentRemoteHosts implements Serializable {
@Serial
private static final long serialVersionUID = 1;
@Getter
private final PersistentRemoteHostsData _data = new PersistentRemoteHostsData();
private final ReadWriteLock _lock = new ReentrantReadWriteLock();

View File

@@ -145,7 +145,7 @@ public class PersistentRemoteHostsService {
}
public String getUniqueId() {
return _selfUuid.toString() + _persistentData.runReadLocked(d -> d.getSelfCounter().addAndGet(1)).toString();
return _selfUuid.toString() + _persistentData.getData().getSelfCounter().addAndGet(1);
}
public PersistentPeerInfo getInfo(UUID name) {