mirror of https://github.com/grafana/loki
Bump go.uber.org/atomic from 1.10.0 to 1.11.0 (#9940)
Bumps [go.uber.org/atomic](https://github.com/uber-go/atomic) from 1.10.0 to 1.11.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/uber-go/atomic/releases">go.uber.org/atomic's releases</a>.</em></p> <blockquote> <h2>v1.11.0</h2> <h3>Fixed</h3> <ul> <li>Fix <code>Swap</code> and <code>CompareAndSwap</code> for <code>Value</code> wrappers without initialization.</li> </ul> <h3>Added</h3> <ul> <li>Add <code>String</code> method to <code>atomic.Pointer[T]</code> type allowing users to safely print underlying values of pointers.</li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/uber-go/atomic/blob/master/CHANGELOG.md">go.uber.org/atomic's changelog</a>.</em></p> <blockquote> <h2><a href="https://github.com/uber-go/atomic/compare/v1.10.0...v1.11.0">1.11.0</a> - 2023-05-02</h2> <h3>Fixed</h3> <ul> <li>Fix <code>Swap</code> and <code>CompareAndSwap</code> for <code>Value</code> wrappers without initialization.</li> </ul> <h3>Added</h3> <ul> <li>Add <code>String</code> method to <code>atomic.Pointer[T]</code> type allowing users to safely print underlying values of pointers.</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="pull/9945/head76f817c8b7"><code>76f817c</code></a> Update CHANGELOG.md</li> <li><a href="2a750c4499"><code>2a750c4</code></a> Preparing release v1.11.0</li> <li><a href="544d6aa5c2"><code>544d6aa</code></a> Minimize permissions to CI workflows (<a href="https://redirect.github.com/uber-go/atomic/issues/133">#133</a>)</li> <li><a href="1505d282ac"><code>1505d28</code></a> Fix Swap and CompareAndSwap for Value wrappers (<a href="https://redirect.github.com/uber-go/atomic/issues/130">#130</a>)</li> <li><a href="78a3b8ec6c"><code>78a3b8e</code></a> Implement String method for pointers (<a href="https://redirect.github.com/uber-go/atomic/issues/122">#122</a>)</li> <li><a href="159e329dd8"><code>159e329</code></a> chore(gen-*): Move templates into external files (<a href="https://redirect.github.com/uber-go/atomic/issues/121">#121</a>)</li> <li>See full diff in <a href="https://github.com/uber-go/atomic/compare/v1.10.0...v1.11.0">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
parent
0fd9331044
commit
85d23c2452
@ -0,0 +1,60 @@ |
||||
// Copyright (c) 2022 Uber Technologies, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
//go:build go1.18 && !go1.19
|
||||
// +build go1.18,!go1.19
|
||||
|
||||
package atomic |
||||
|
||||
import "unsafe" |
||||
|
||||
type Pointer[T any] struct { |
||||
_ nocmp // disallow non-atomic comparison
|
||||
p UnsafePointer |
||||
} |
||||
|
||||
// NewPointer creates a new Pointer.
|
||||
func NewPointer[T any](v *T) *Pointer[T] { |
||||
var p Pointer[T] |
||||
if v != nil { |
||||
p.p.Store(unsafe.Pointer(v)) |
||||
} |
||||
return &p |
||||
} |
||||
|
||||
// Load atomically loads the wrapped value.
|
||||
func (p *Pointer[T]) Load() *T { |
||||
return (*T)(p.p.Load()) |
||||
} |
||||
|
||||
// Store atomically stores the passed value.
|
||||
func (p *Pointer[T]) Store(val *T) { |
||||
p.p.Store(unsafe.Pointer(val)) |
||||
} |
||||
|
||||
// Swap atomically swaps the wrapped pointer and returns the old value.
|
||||
func (p *Pointer[T]) Swap(val *T) (old *T) { |
||||
return (*T)(p.p.Swap(unsafe.Pointer(val))) |
||||
} |
||||
|
||||
// CompareAndSwap is an atomic compare-and-swap.
|
||||
func (p *Pointer[T]) CompareAndSwap(old, new *T) (swapped bool) { |
||||
return p.p.CompareAndSwap(unsafe.Pointer(old), unsafe.Pointer(new)) |
||||
} |
||||
Loading…
Reference in new issue