utils

package
v0.0.0-...-2f8f7b3 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoRun

func GoRun(f Func)

func GoRunArgs

func GoRunArgs(f FuncArgs, args ...interface{})

func TimeLoop

func TimeLoop(idleTime time.Duration, f Func)

func TimeLoopArgs

func TimeLoopArgs(idleTime time.Duration, f FuncArgs, args ...interface{})

Types

type Func

type Func func()

type FuncArgs

type FuncArgs func(args ...interface{})

type Task

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

func NewTask

func NewTask(f taskFunc, args ...interface{}) *Task

func (*Task) Execute

func (t *Task) Execute() error

type TaskPool

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

================================================================ 多个线程,一个任务队列,多个线程竞争从队列中获取任务并执行

func NewTaskPool

func NewTaskPool(threadSize, taskQueueSize int) *TaskPool

func (*TaskPool) Start

func (t *TaskPool) Start()

func (*TaskPool) Stop

func (t *TaskPool) Stop()

func (*TaskPool) Submit

func (t *TaskPool) Submit(task *Task)

type Thread

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

=====================================================================

type ThreadPool

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

开启多个线程,每个线程都有一个独立的任务队列,所有队列并行执行

func NewThreadPool

func NewThreadPool(poolSize, threadWorkSize int) *ThreadPool

func (*ThreadPool) Start

func (d *ThreadPool) Start()

func (*ThreadPool) Stop

func (d *ThreadPool) Stop()

func (*ThreadPool) Submit

func (d *ThreadPool) Submit(threadId int, task *Task)

Jump to

Keyboard shortcuts

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