122 |
|
/* |
123 |
|
* The underlying algorithm here is a simplified adaptation of |
124 |
|
* that used for ReentrantLock. See the internal documentation of |
125 |
< |
* ReentrantLock for detailed explanation. |
125 |
> |
* lock package classes for detailed explanation. |
126 |
|
*/ |
127 |
|
|
128 |
|
private static final long serialVersionUID = -3222578661600680210L; |
219 |
|
* @return remaining number of permits |
220 |
|
*/ |
221 |
|
private int doTryAcquire(int permits) { |
222 |
+ |
final AtomicInteger perms = this.perms; |
223 |
|
for (;;) { |
224 |
|
int available = perms.get(); |
225 |
|
int remaining = available - permits; |
348 |
|
* Internal version of release |
349 |
|
*/ |
350 |
|
private void doRelease(int permits) { |
351 |
+ |
final AtomicInteger perms = this.perms; |
352 |
|
for (;;) { |
353 |
|
int p = perms.get(); |
354 |
|
if (perms.compareAndSet(p, p + permits)) { |