-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix:use reentrantLock instead of spinlock #987
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #987 +/- ##
=============================================
- Coverage 38.45% 38.44% -0.02%
Complexity 1046 1046
=============================================
Files 218 218
Lines 8687 8681 -6
Branches 1081 1078 -3
=============================================
- Hits 3341 3337 -4
Misses 4924 4924
+ Partials 422 420 -2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM,
ps: if without considering more powerful lock in the future, maybe we can use ReentrantLock directly. do not need to be warpped by GlobalSessionLock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ⅰ. Describe what this PR did
I'm sorry that I used spinLock in the wrong way before. The advantage of spinLock is that there is no need for thread context switch, but locksupport.park caused thread switch.
And SpinLock is good for locking parts to execute quickly, but we have IO operations in our changeStatus which is locking part, so to prevent CPU waste, I think ReentrantLock is more appropriate.
SpinLock can be seen as doing CAS all the time.The ReentrantLock lock the first time is CAS then it will be parked.
Ⅱ. Does this pull request fix one issue?
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews