Skip to content
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

remove custom trylock in favor of stock sync.Mutex #1886

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
working-directory: ./cmd/dcrdata

- 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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current version master is v1.55.2, consider updating to v1.58.0


- name: Go Tests
env:
Expand Down
8 changes: 6 additions & 2 deletions trylock/trylock.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) 2021, The Decred developers
// Copyright (c) 2021-2022, The Decred developers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can update this the next time you commit.

// See LICENSE for details.

//go:build !go1.18
// +build !go1.18

package trylock

import (
Expand All @@ -11,7 +14,8 @@ import (

// Mutex is a "try lock" for coordinating multiple accessors, while allowing
// only a single updater. It is not very smart about queueing when there are
// multiple callers of Lock waiting.
// multiple callers of Lock waiting. DEPRECATED: sync.Mutex has TryLock
// functionality built-in as of Go 1.18.
type Mutex struct {
mtx sync.Mutex
c chan struct{}
Expand Down
13 changes: 13 additions & 0 deletions trylock/trylock_go1.18.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) 2022, The Decred developers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This too.

// See LICENSE for details.

//go:build go1.18
// +build go1.18

package trylock

import "sync"

// Mutex is just an alias for sync.Mutex in Go 1.18 onward since TryLock() was
// added to the standard library.
type Mutex = sync.Mutex