WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 438a50b

Browse files
committed
Avoid allocating the double - remove unused methods
1 parent d3143ce commit 438a50b

File tree

2 files changed

+5
-25
lines changed

2 files changed

+5
-25
lines changed

utils/queue-utils/src/main/java/datadog/common/queue/BaseQueue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected BaseQueue(int requestedCapacity) {
5151
protected BaseQueue(int capacity, int mask) {
5252
this.capacity = capacity;
5353
this.mask = mask;
54-
this.buffer = (E[]) new Object[capacity << (CACHE_LINE_SHIFT + 1)];
54+
this.buffer = (E[]) new Object[capacity << CACHE_LINE_SHIFT];
5555
}
5656

5757
/**

utils/queue-utils/src/main/java/datadog/common/queue/MpscBlockingConsumerArrayQueueVarHandle.java

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ public final class MpscBlockingConsumerArrayQueueVarHandle<E> extends BaseQueue<
2828
/** The consumer thread that to be woken up if the customer blocked on take() */
2929
private final PaddedThread blocked = new PaddedThread();
3030

31-
/**
32-
* Store producer limit with release semantics.
33-
*
34-
* @param value new producer limit
35-
*/
36-
private void soProducerLimit(long value) {
37-
producerLimit.setRelease(value);
38-
}
39-
4031
/**
4132
* Load producer limit with opaque semantics (best for hot path). Opaque prevents compiler
4233
* reordering but has no CPU fence overhead. Safe because racy updates are benign - stale reads
@@ -49,14 +40,12 @@ private long lpProducerLimit() {
4940
}
5041

5142
/**
52-
* Load producer limit with acquire semantics.
43+
* Compare and Swap for the producer limit.
5344
*
54-
* @return current producer limit
45+
* @param expect
46+
* @param update
47+
* @return
5548
*/
56-
private long laProducerLimit() {
57-
return producerLimit.getAcquire();
58-
}
59-
6049
private boolean casProducerLimit(long expect, long update) {
6150
return producerLimit.compareAndSet(expect, update);
6251
}
@@ -80,15 +69,6 @@ private Thread lpBlocked() {
8069
return blocked.getOpaque();
8170
}
8271

83-
/**
84-
* Load blocked thread with acquire semantics.
85-
*
86-
* @return current blocked thread if any
87-
*/
88-
private Thread laBlocked() {
89-
return blocked.getAcquire();
90-
}
91-
9272
/**
9373
* Creates queue with specified capacity.
9474
*

0 commit comments

Comments
 (0)