mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
waste less cycles when quick deleting
otherwise that .wait is using quite a lot
This commit is contained in:
@@ -451,7 +451,6 @@ public class DhfsFileServiceImpl implements DhfsFileService {
|
||||
m.removeRef(f.getName());
|
||||
return null;
|
||||
});
|
||||
jObjectManager.tryQuickDelete(ci.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,11 +223,11 @@ public class JObjectManagerImpl implements JObjectManager {
|
||||
|
||||
object.discardData();
|
||||
|
||||
refs.forEach(c -> get(c).ifPresent(ref -> ref.runWriteLocked(JObject.ResolutionStrategy.NO_RESOLUTION, (mc, dc, bc, ic) -> {
|
||||
mc.removeRef(object.getName());
|
||||
tryQuickDelete(ref);
|
||||
return null;
|
||||
})));
|
||||
refs.forEach(c -> get(c)
|
||||
.ifPresent(ref -> ref.runWriteLocked(JObject.ResolutionStrategy.NO_RESOLUTION, (mc, dc, bc, ic) -> {
|
||||
mc.removeRef(object.getName());
|
||||
return null;
|
||||
})));
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -45,9 +45,9 @@ public class JObjectRefProcessor {
|
||||
private final LinkedHashMap<String, Long> _candidates = new LinkedHashMap<>();
|
||||
|
||||
public void putDeletionCandidate(String name) {
|
||||
synchronized (this) {
|
||||
synchronized (_candidates) {
|
||||
if (_candidates.putIfAbsent(name, System.currentTimeMillis()) == null)
|
||||
this.notify();
|
||||
_candidates.notify();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ public class JObjectRefProcessor {
|
||||
String next;
|
||||
Long nextTime;
|
||||
|
||||
synchronized (this) {
|
||||
synchronized (_candidates) {
|
||||
while (_candidates.isEmpty())
|
||||
this.wait();
|
||||
_candidates.wait();
|
||||
|
||||
var e = _candidates.firstEntry();
|
||||
next = e.getKey();
|
||||
|
||||
@@ -88,7 +88,10 @@ public class JObjectResolver {
|
||||
|
||||
if (self.getMeta().getRefcount() <= 0)
|
||||
if (!self.isDeleted())
|
||||
jObjectRefProcessor.putDeletionCandidate(self.getName());
|
||||
if (self.getMeta().isSeen())
|
||||
jObjectRefProcessor.putDeletionCandidate(self.getName());
|
||||
else
|
||||
jobjectManager.tryQuickDelete(self);
|
||||
}
|
||||
|
||||
public <T extends JObjectData> Optional<T> resolveDataLocal(JObject<T> jObject) {
|
||||
|
||||
@@ -143,13 +143,16 @@ public class JObjectWriteback {
|
||||
flushOne(obj);
|
||||
} catch (Exception e) {
|
||||
Log.error("Failed writing object " + obj.getName() + ", will retry.", e);
|
||||
obj.runReadLocked(JObject.ResolutionStrategy.NO_RESOLUTION, (m, d) -> {
|
||||
var size = jObjectSizeEstimator.estimateObjectSize(d);
|
||||
synchronized (_writeQueue) {
|
||||
_writeQueue.put(Pair.of(size, m.getName()), obj);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
try {
|
||||
obj.runReadLocked(JObject.ResolutionStrategy.NO_RESOLUTION, (m, d) -> {
|
||||
var size = jObjectSizeEstimator.estimateObjectSize(d);
|
||||
synchronized (_writeQueue) {
|
||||
_writeQueue.put(Pair.of(size, m.getName()), obj);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
} catch (JObject.DeletedObjectAccessException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException ignored) {
|
||||
|
||||
Reference in New Issue
Block a user