mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
waste less cpu cycles when incrementing local counter
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user