remove custom trylock in favor of stock sync.Mutex#1886
Open
chappjc wants to merge 1 commit intodecred:masterfrom
Open
remove custom trylock in favor of stock sync.Mutex#1886chappjc wants to merge 1 commit intodecred:masterfrom
chappjc wants to merge 1 commit intodecred:masterfrom
Conversation
2eadf2c to
7db6f74
Compare
Go 1.18 supplements Mutex with a TryLock method. Use this directly instead of our dumb homebrew trylock mutex when Go 1.18 is in use.
7db6f74 to
db9fd08
Compare
ukane-philemon
requested changes
Jun 6, 2024
Collaborator
ukane-philemon
left a comment
There was a problem hiding this comment.
Looks straight-forward.
|
|
||
| - name: Install Linters | ||
| run: "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.48.0" | ||
| run: "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.1" |
Collaborator
There was a problem hiding this comment.
current version master is v1.55.2, consider updating to v1.58.0
| @@ -1,6 +1,9 @@ | |||
| // Copyright (c) 2021, The Decred developers | |||
| // Copyright (c) 2021-2022, The Decred developers | |||
Collaborator
There was a problem hiding this comment.
Can update this the next time you commit.
| @@ -0,0 +1,13 @@ | |||
| // Copyright (c) 2022, The Decred developers | |||
Collaborator
|
@dajohi wdyt? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Go 1.18 supplements
Mutexwith aTryLockmethod. For the on-demand concurrent client accesses to the cache-guarded DB, use this directly instead of our dumb homebrew trylock mutex when Go 1.18 is in use.IMPORTANT NOTES:
if !TryLock() { if haveCachedData { /* return stale data */ } else { Lock() /* wait */ } }solves this quite handily. This has been functioning well in production for quite some time.The use case in pseudo code:
An alternative approach that does not involve locking to wait on the data, but rather a channel to receive from, used elsewhere in the project:
dcrdata/db/cache/addresscache.go
Lines 56 to 65 in 429ab90
Also update CI to use go 1.18-beta1.