dispatcher

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2019 License: MIT Imports: 3 Imported by: 0

README

dispatcher

about

dispatcher is a function scheduler that dispatches a limited number of functions and keeps rest of the functions in a list for dispatching later.

use

import pkg

import github.com/sdeoras/dispatcher

dispatch function

d := dispatcher.New(5) // dispatch a max of 5 functions concurrently
d.Do(func(){
	fmt.Println("dispatched")
})

wait for completion

for d.IsRunning() {
	time.Sleep(time.Second)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(numConcurrent int32) *dispatcher

New provides a new instance of dispatcher

Types

type Dispatcher

type Dispatcher interface {
	// Do causes function to be scheduled for execution.
	// Execution trigger is implementation specific.
	Do(f func())
	// IsRunning provides activity status of the dispatcher
	IsRunning() bool
}

Dispatcher defines an interface for a function dispatcher

Jump to

Keyboard shortcuts

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