/fastq

High performance lock free queue in offheap, like disruptor

Primary LanguageGo

fastq

High performance lock-free queue in offheap

Usage

package main

import (
	"fmt"

	"github.com/rfyiamcool/fastq"
)

func main() {
	fastq.Init()
	msg := &fastq.Message{
		Module:     "xiaorui.cc",
		Msg:        "i love u",
		RetryTimes: 1,
	}

	var count = 100
	for index := 0; index < count; index++ {
		err := fastq.Write(msg)
		fmt.Println(err)
	}

	for index := 0; index < count; index++ {
		module, message, err := fastq.Read()
		fmt.Println(index, module, message)
		if module != msg.Module {
			panic("err")
		}

		if message != msg.Msg {
			panic("err")
		}

		if err != nil {
			panic(err.Error())
		}
	}
}