mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-28 12:37:48 +01:00
Server: no delay op sending
This commit is contained in:
@@ -65,7 +65,7 @@ public class OpPusher {
|
||||
|
||||
if (tree.hasPendingOpsForHost(entry.peer())) {
|
||||
doAgain.set(true);
|
||||
invalidationQueueService.pushInvalidationToOne(entry.peer(), pd.key());
|
||||
invalidationQueueService.pushInvalidationToOneNoDelay(entry.peer(), pd.key());
|
||||
}
|
||||
return ops;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,24 @@ public class HashSetDelayedBlockingQueue<T> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Adds the object to the queue, if it exists re-adds it
|
||||
// With no delay
|
||||
// Returns the old object, or null
|
||||
public T addNoDelay(T el) {
|
||||
synchronized (this) {
|
||||
if (_closed) throw new IllegalStateException("Adding to a queue that is closed!");
|
||||
|
||||
SetElement<T> old = _set.putFirst(el, new SetElement<>(el, 0));
|
||||
this.notify();
|
||||
|
||||
if (old != null)
|
||||
return old.el();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Adds the object to the queue, if it exists re-adds it with a new delay
|
||||
// Returns the old object, or null
|
||||
public T readd(T el) {
|
||||
|
||||
@@ -24,6 +24,19 @@ public class HashSetDelayedBlockingQueueTest {
|
||||
Assertions.assertTrue((gotTime - curTime) >= 1000);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void addNoDelay() throws InterruptedException {
|
||||
var queue = new HashSetDelayedBlockingQueue<>(1000);
|
||||
|
||||
var curTime = System.currentTimeMillis();
|
||||
queue.addNoDelay("hello!");
|
||||
var thing = queue.get();
|
||||
var gotTime = System.currentTimeMillis();
|
||||
Assertions.assertEquals("hello!", thing);
|
||||
Assertions.assertTrue((gotTime - curTime) < 500);
|
||||
}
|
||||
|
||||
@Test
|
||||
void GetImmediate() throws InterruptedException {
|
||||
var queue = new HashSetDelayedBlockingQueue<>(0);
|
||||
|
||||
Reference in New Issue
Block a user