renamed queue
This commit is contained in:
parent
4276f881e8
commit
ac4e396f5d
|
@ -2,6 +2,7 @@ package dorkbox.util.messagebus.common.simpleq;
|
|||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import dorkbox.util.messagebus.common.simpleq.jctools.MpmcArrayTransferQueue;
|
||||
import dorkbox.util.messagebus.common.simpleq.jctools.Pow2;
|
||||
|
||||
public final class SimpleQueue {
|
||||
|
@ -41,17 +42,17 @@ public final class SimpleQueue {
|
|||
*/
|
||||
static final long spinForTimeoutThreshold = 1000L;
|
||||
|
||||
private MpmcExchangerQueue queue;
|
||||
private MpmcArrayTransferQueue queue;
|
||||
|
||||
public SimpleQueue(final int size) {
|
||||
this.queue = new MpmcExchangerQueue(Pow2.roundToPowerOfTwo(size));
|
||||
this.queue = new MpmcArrayTransferQueue(Pow2.roundToPowerOfTwo(size));
|
||||
}
|
||||
|
||||
/**
|
||||
* PRODUCER
|
||||
*/
|
||||
public void put(Object item) throws InterruptedException {
|
||||
this.queue.xfer(item, false, 0, MpmcExchangerQueue.TYPE_PRODUCER);
|
||||
this.queue.xfer(item, false, 0, MpmcArrayTransferQueue.TYPE_PRODUCER);
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,7 +62,7 @@ public final class SimpleQueue {
|
|||
public Object take() throws InterruptedException {
|
||||
// this.queue.xfer(123, false, 0, MpmcExchangerQueue.TYPE_PRODUCER);
|
||||
// return 123;
|
||||
return this.queue.xfer(null, false, 0, MpmcExchangerQueue.TYPE_CONSUMER);
|
||||
return this.queue.xfer(null, false, 0, MpmcArrayTransferQueue.TYPE_CONSUMER);
|
||||
}
|
||||
|
||||
private Object xfer(Object item, boolean timed, long nanos, byte incomingType) throws InterruptedException {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package dorkbox.util.messagebus.common.simpleq;
|
||||
package dorkbox.util.messagebus.common.simpleq.jctools;
|
||||
|
||||
import static dorkbox.util.messagebus.common.simpleq.jctools.UnsafeAccess.UNSAFE;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.locks.LockSupport;
|
||||
|
||||
import dorkbox.util.messagebus.common.simpleq.jctools.MpmcArrayQueueConsumerField;
|
||||
import dorkbox.util.messagebus.common.simpleq.Node;
|
||||
|
||||
public final class MpmcExchangerQueue extends MpmcArrayQueueConsumerField<Node> {
|
||||
public final class MpmcArrayTransferQueue extends MpmcArrayQueueConsumerField<Node> {
|
||||
|
||||
public static final int TYPE_FREE = 0;
|
||||
public static final int TYPE_CONSUMER = 1;
|
||||
|
@ -84,7 +84,7 @@ public final class MpmcExchangerQueue extends MpmcArrayQueueConsumerField<Node>
|
|||
long p30, p31, p32, p33, p34, p35, p36, p37;
|
||||
|
||||
/** Creates a {@code EliminationStack} that is initially empty. */
|
||||
public MpmcExchangerQueue(final int size) {
|
||||
public MpmcArrayTransferQueue(final int size) {
|
||||
super(size);
|
||||
|
||||
// pre-fill our data structures
|
Loading…
Reference in New Issue
Block a user