ibessonov commented on code in PR #7514:
URL: https://github.com/apache/ignite-3/pull/7514#discussion_r2758848068
##########
modules/core/src/main/java/org/apache/ignite/internal/util/OffheapReadWriteLock.java:
##########
@@ -507,14 +536,73 @@ private boolean waitAcquireWriteLock(long lock, int
lockIdx, int tag) {
}
}
+ private boolean tryReleaseReadWaiter(long lock, int lockIdx, long state) {
+ long updated = updateState(state, 0, -1, 0);
+
+ if (GridUnsafe.compareAndSwapLong(null, lock, state, updated)) {
+ int writeWaitCnt = writersWaitCount(updated);
+
+ signalNextWaiter(writeWaitCnt, lockIdx);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ private boolean tryReleaseWriteWaiter(long lock, int lockIdx, long state) {
+ long updated = updateState(state, 0, 0, -1);
+
+ if (GridUnsafe.compareAndSwapLong(null, lock, state, updated)) {
+ int writeWaitCnt = writersWaitCount(updated);
+
+ signalNextWaiter(writeWaitCnt, lockIdx);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ @SuppressWarnings("AwaitNotInLoop")
+ private void awaitCondition(
+ long lock, int lockIdx, int tag, long startTimeNanos, Condition
waitCond, boolean readLock
+ ) throws InterruptedException {
+ if (timeoutNanos == 0) {
+ waitCond.await();
+ } else {
+ long passedNanos = System.nanoTime() - startTimeNanos;
+
+ if (passedNanos >= timeoutNanos) {
+ //noinspection InfiniteLoopStatement
+ while (true) {
+ long state = GridUnsafe.getLongVolatile(null, lock);
+
+ if (readLock ? tryReleaseReadWaiter(lock, lockIdx, state)
: tryReleaseWriteWaiter(lock, lockIdx, state)) {
+ throw new LockTimeoutException(S.toString("Timeout
waiting for lock acquisition",
+ "lock", hexLong(lock), false,
+ "state", hexLong(state), false,
+ "tag", hexInt(tag), false,
+ "idx", lockIdx, false,
+ "cond", waitCond.toString(), false,
+ "timeout",
TimeUnit.NANOSECONDS.toMillis(timeoutNanos) + "ms", false
Review Comment:
It's not necessary, I already add "ms" to the value
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]