Skip to content

Commit

Permalink
docs(backPressure): add comments for DCL.
Browse files Browse the repository at this point in the history
  • Loading branch information
PhantomThief committed Oct 13, 2020
1 parent dd54b63 commit 5923c9f
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ public void enqueue(E element) {
boolean pass = false;
if (rejectHandler != null) {
if (writeLock != null && writeCondition != null) {
writeLock.lock();
writeLock.lock(); // 这里采用 DCL,是为了避免部分消费情况下没有 signalAll 唤醒,导致的卡死问题
// 判断堵塞的条件也的确应该在锁块内保护,之前的代码在临界区(counter)的保护上是有缺陷的
}
try {
currentCount = counter.get();
Expand Down

0 comments on commit 5923c9f

Please sign in to comment.