pointer_unsafe.go 494 B

1234567891011121314151617
  1. // Copyright 2024 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package protolazy
  5. import (
  6. "sync/atomic"
  7. "unsafe"
  8. )
  9. func atomicLoadIndex(p **[]IndexEntry) *[]IndexEntry {
  10. return (*[]IndexEntry)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
  11. }
  12. func atomicStoreIndex(p **[]IndexEntry, v *[]IndexEntry) {
  13. atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
  14. }