Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
issue50993.go36 linesDownload Raw Back to typeparam
1// compile -d=checkptr2 3// Copyright 2022 The Go Authors. All rights reserved.4// Use of this source code is governed by a BSD-style5// license that can be found in the LICENSE file.6 7package main8 9import (10	"sync/atomic"11	"unsafe"12)13 14type Node[T any] struct {15	Next *Node[T]16	// Prev  *Node[T]17}18 19func LoadPointer[T any](addr **T) (val *T) {20	return (*T)(21		atomic.LoadPointer(22			(*unsafe.Pointer)(unsafe.Pointer(addr)),23		))24}25 26func (q *Node[T]) Pop() {27	var tail, head *Node[T]28	if head == LoadPointer(&tail) {29	}30}31 32func main() {33	ch := Node[uint64]{}34	ch.Pop()35}36 
codekingpro/portable-devtools · Team Ai