gitee.com/sy_183/go-common@v1.0.5-0.20231205030221-958cfe129b47/ipc/cgo/shm-server/channel.go (about)

     1  package shmServer
     2  
     3  import (
     4  	"gitee.com/sy_183/go-common/ipc/cgo/sem/queue"
     5  	shmPkg "gitee.com/sy_183/go-common/ipc/cgo/shm"
     6  	"sync/atomic"
     7  	"unsafe"
     8  )
     9  
    10  type Channel struct {
    11  	addrId  AddrId
    12  	shm     *shmPkg.Shm
    13  	queue32 *queue.Queue32
    14  	raw     []byte
    15  }
    16  
    17  func newChannel(addrId AddrId) *Channel {
    18  	return &Channel{addrId: addrId}
    19  }
    20  
    21  func (c *Channel) loadQueue() *queue.Queue32 {
    22  	return (*queue.Queue32)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&c.queue32))))
    23  }