Help us shape the future of Go! Take the 2026 Go Developer Survey

worker

package module
v0.0.0-...-5f16f82 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: MIT Imports: 1 Imported by: 0

README

Sync / Async serial worker queue (GCD)

basic functionality you would expect from: https://developer.apple.com/reference/dispatch

builds

Build Status

example

GCD style serial execution of function (lambdas / blocks)

  import "github.com/korovkin/worker"
  ...

  w := worker.NewWorkerDefault("test")
  for i := 0; i < 1000; i++ {
    i := i
    worker.Enqueue(func() {
        fmt.Println(" async: i:", i)
    })
  }
  worker.EnqueueSync(func() {
      fmt.Println("sync!")
  })

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Worker

type Worker struct {
	Name string
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(name string, queue chan WorkerJob) *Worker

func NewWorkerDefault

func NewWorkerDefault(name string) *Worker

func (*Worker) Close

func (w *Worker) Close()

func (*Worker) Enqueue

func (w *Worker) Enqueue(job func())

func (*Worker) EnqueueSync

func (w *Worker) EnqueueSync(job func())

func (*Worker) GetQueueSize

func (w *Worker) GetQueueSize() int

func (*Worker) Stop

func (w *Worker) Stop(job func())

type WorkerJob

type WorkerJob struct {
	Job func()
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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