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

tools/checklocks: support field comments for guard specifications #10576

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

copybara-service[bot]
Copy link

tools/checklocks: support field comments for guard specifications

This allows specifying guards in the format:

type foo struct {
    mu  sync.Mutex
    bar int // +checklocks:mu
}

This syntax, while more limited, makes writing lock guards less verbose for structures where field documentation isn't attached to each field. For example, being able to write something like the following with field comments reduces the number of lines in the struct by >25% and is, in my opinion, easier to read.

type widget struct {
    mu sync.Mutex // guards following

    // The following counters track [...]

    success  int // +checklocks:mu
    failure  int // +checklocks:mu
    retries  int // +checklocks:mu
    timeouts int // +checklocks:mu
}

FUTURE_COPYBARA_INTEGRATE_REVIEW=#10575 from andrew-d:andrew/checklocks-field-comment e3db6f0

This allows specifying guards in the format:

    type foo struct {
        mu  sync.Mutex
        bar int // +checklocks:mu
    }

This syntax, while more limited, makes writing lock guards less verbose for structures where field documentation isn't attached to each field. For example, being able to write something like the following with field comments reduces the number of lines in the struct by >25% and is, in my opinion, easier to read.

    type widget struct {
        mu sync.Mutex // guards following

        // The following counters track [...]

        success  int // +checklocks:mu
        failure  int // +checklocks:mu
        retries  int // +checklocks:mu
        timeouts int // +checklocks:mu
    }

FUTURE_COPYBARA_INTEGRATE_REVIEW=#10575 from andrew-d:andrew/checklocks-field-comment e3db6f0
PiperOrigin-RevId: 647013788
@copybara-service copybara-service bot added the exported Issue was exported automatically label Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exported Issue was exported automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant