pointer_unsafe.go

 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
 5package protolazy
 6
 7import (
 8	"sync/atomic"
 9	"unsafe"
10)
11
12func atomicLoadIndex(p **[]IndexEntry) *[]IndexEntry {
13	return (*[]IndexEntry)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
14}
15func atomicStoreIndex(p **[]IndexEntry, v *[]IndexEntry) {
16	atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
17}