queue

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2021 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NoneBlockQueue

type NoneBlockQueue struct {
	// contains filtered or unexported fields
}

func NewNoneBlockQueue

func NewNoneBlockQueue(size int) *NoneBlockQueue

func (*NoneBlockQueue) Fetch

func (q *NoneBlockQueue) Fetch() (interface{}, bool)

func (*NoneBlockQueue) Put

func (q *NoneBlockQueue) Put(item interface{}) bool

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue(size int) *Queue
Example
package main

import (
	"fmt"
	"github.com/hetianyi/gox/queue"
	"time"
)

func main() {
	q := queue.NewQueue(2)

	go func() {
		for i := 0; i < 10; i++ {
			fmt.Println("添加:", i)
			q.Put(i)
			fmt.Println("添加结束:", i)
		}
	}()
	go func() {
		for true {
			fmt.Println("得到:", q.Fetch())
			time.Sleep(time.Second)
		}
	}()
	time.Sleep(time.Second * 20)
}
Output:

func (*Queue) Fetch

func (q *Queue) Fetch() interface{}

func (*Queue) Put

func (q *Queue) Put(item interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL