Hi,majumdar. I found there may be a small mistake in locking in SimpleDBM.
Please check and confirm.
I used your complete jar to help implementing the locking in my project, but I
found that the no timeout lock can throw timeout exception sometimes,
I read your codes carefully, and found there may be a small mistake when
timeToWait = -1. The red color code is the change i try to solve the problem.
Will you please
check and fix it in your best way you think and release an new version ? For your license reason, I can not change your code.
Thanks a lot!
Sincerely Water Chow.
--------------------------------------------------------------------------------
-----------------------------
public boolean isExpired() {
if (expired)
return true;
if (timeToWait == -1)
return false;
long now = System.nanoTime();
long timeWaited = now - startTime;
if (timeWaited >= timeToWait) {
expired = true;
}
return expired;
}
public void await() {
if (expired) {
return;
}
if (timeToWait == -1) {
LockSupport.park();
// expired = true;
return;
}
long now = System.nanoTime();
long timeWaited = now - startTime;
if (timeWaited >= timeToWait) {
expired = true;
return;
}
long timeToWaitThisTime = timeToWait - timeWaited;
assert timeToWaitThisTime > 0 && timeToWaitThisTime <= timeToWait;
LockSupport.parkNanos(timeToWaitThisTime);
}
Original issue reported on code.google.com by d.majum...@gmail.com on 19 Dec 2011 at 10:10
Original issue reported on code.google.com by
d.majum...@gmail.com
on 19 Dec 2011 at 10:10