| | |
| | | import ( |
| | | "context" |
| | | "fmt" |
| | | "github.com/gen2brain/shm" |
| | | shm "basic.com/valib/goshm.git" |
| | | "reflect" |
| | | "runtime" |
| | | "sync/atomic" |
| | |
| | | ) |
| | | |
| | | const ( |
| | | TimePeriodPutOrGet = time.Duration(5) * time.Microsecond |
| | | TimePeriodPutOrGet = time.Duration(5)*time.Millisecond //ms |
| | | ) |
| | | |
| | | //Element info |
| | |
| | | shmLen = shmblocks*uint32(unsafe.Sizeof(datainfo)) + uint32(unsafe.Sizeof(shmstruct)) |
| | | |
| | | data, shmid := CreateRawShm(ctx, int(shmLen), key) |
| | | if shmid == -1 { |
| | | return nil |
| | | } |
| | | q := bytes2shmEsQueue(data) |
| | | //init parameters |
| | | q.capacity = shmblocks |
| | |
| | | func AttachQueue(ctx context.Context, key int) *EsQueueInfo { |
| | | |
| | | var eqi EsQueueInfo |
| | | data, shmid := AttachRawShm(ctx, key) |
| | | data, shmid := AttachRawShmTimeout(ctx, key) |
| | | if shmid == -1 { |
| | | return nil |
| | | } |
| | | shmdata := bytes2shmEsQueue(data) |
| | | eqi.EsCaches = ptr2esCache(unsafe.Pointer(&shmdata.cache), int(shmdata.capacity)) |
| | | //fmt.Println("AttachQueue EsCaches:", eqi.EsCaches) |