job

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: MIT Imports: 4 Imported by: 0

README

job-scheduler

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelScheduler added in v0.2.0

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

func NewChannelScheduler added in v0.2.0

func NewChannelScheduler(ctx context.Context, concurrent int) *ChannelScheduler

NewChannelScheduler creates a new scheduler.

func (*ChannelScheduler) Add added in v0.2.0

func (s *ChannelScheduler) Add(job func()) error

func (*ChannelScheduler) SetQueueSize added in v0.2.0

func (s *ChannelScheduler) SetQueueSize(size int)

func (*ChannelScheduler) Start added in v0.2.0

func (s *ChannelScheduler) Start()

type QueueScheduler added in v0.2.0

type QueueScheduler struct {
	// contains filtered or unexported fields
}
Example
s := job.NewQueueScheduler(1)

var wg sync.WaitGroup
wg.Add(3)
s.Add(func() {
	defer wg.Done()
	fmt.Printf("hello")
})
s.Add(func() {
	defer wg.Done()
	fmt.Printf(" ")
})
s.Add(func() {
	defer wg.Done()
	fmt.Println("world")
})

wg.Wait()
Output:

hello world

func NewQueueScheduler added in v0.2.0

func NewQueueScheduler(concurrent int64) *QueueScheduler

func (*QueueScheduler) Add added in v0.2.0

func (s *QueueScheduler) Add(job func())

Jump to

Keyboard shortcuts

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