-
Notifications
You must be signed in to change notification settings - Fork 7
/
LocalFifoQueue.java
42 lines (34 loc) · 1008 Bytes
/
LocalFifoQueue.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - [email protected]
*/
package sirius.biz.cluster.work;
import com.fasterxml.jackson.databind.node.ObjectNode;
import sirius.kernel.commons.Explain;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* Provides a local (single machine) implementation for a FIFO.
*/
class LocalFifoQueue implements FifoQueue {
private final ConcurrentLinkedQueue<ObjectNode> queue = new ConcurrentLinkedQueue<>();
@Override
public void offer(@Nonnull ObjectNode task) {
queue.offer(task);
}
@Nullable
@Override
public ObjectNode poll() {
return queue.poll();
}
@Override
@SuppressWarnings("squid:S2250")
@Explain("This performance hotspot is acceptable as this is only a monitoring API")
public int size() {
return queue.size();
}
}