package
0.0.0-20200630105701-a377ca4f0e1f
Repository: https://github.com/ops-cn/common.git
Documentation: pkg.go.dev

# README

queue

A task queue for mitigating server pressure in high concurrency situations and improving task processing.

Build Codecov ReportCard GoDoc License

Get

go get -u -v github.com/LyricTian/queue

Usage

package main

import (
	"fmt"

	"github.com/LyricTian/queue"
)

func main() {
	q := queue.NewQueue(10, 100)
	q.Run()

	defer q.Terminate()

	job := queue.NewJob("hello", func(v interface{}) {
		fmt.Printf("%s,world \n", v)
	})
	q.Push(job)

	// output: hello,world
}

MIT License

    Copyright (c) 2017 Lyric

# Functions

NewJob create an asynchronous task.
NewListQueue create a list queue that specifies the number of worker threads.
NewListQueueWithMaxLen create a list queue that specifies the number of worker threads and the maximum number of elements.
NewQueue create a queue that specifies the number of buffers and the number of worker threads.
NewSyncJob create a synchronization task.
Push put the executable task into the queue.
Run start running queues, specify the number of buffers, and the number of worker threads.
RunListQueue start running list queues ,specify the number of worker threads.
Terminate terminate the queue to receive the task and release the resource.

# Structs

ListQueue a list task queue for mitigating server pressure in high concurrency situations and improving task processing.
Queue a task queue for mitigating server pressure in high concurrency situations and improving task processing.

# Interfaces

Jober an asynchronous task that can be executed.
Queuer a task queue for mitigating server pressure in high concurrency situations and improving task processing.
SyncJober a synchronization task that can be executed.