routine

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

Close global routines.

func Go

func Go(fnc func())

Go run routine and add wait group.

Example
package main

import (
	"fmt"
	"time"

	"gitoa.ru/go-4devs/closer/routine"
)

func main() {
	defer routine.Close()
	routine.Go(func() {
		time.Sleep(time.Microsecond)
		fmt.Print("do some job")
	})

}
Output:

do some job

func Run

func Run(fnc ...func())

Run run routines and add wait group.

Example
package main

import (
	"fmt"
	"time"

	"gitoa.ru/go-4devs/closer/routine"
)

func main() {
	defer routine.Close()

	routine.Run(func() {
		time.Sleep(time.Microsecond)
		fmt.Print("do some job. ")
	}, func() {
		fmt.Print("fast job in goroutine. ")
	})

}
Output:

fast job in goroutine. do some job.

func Wait

func Wait()

Wait wait all go routines.

Types

type WaitGroup

type WaitGroup struct {
	sync.WaitGroup
}

WaitGroup run func and wait when done.

func (*WaitGroup) Close

func (wg *WaitGroup) Close() error

Close wait all routines and implement Closer.

func (*WaitGroup) Go

func (wg *WaitGroup) Go(fnc func())

Go add wait group to routines.

func (*WaitGroup) Run

func (wg *WaitGroup) Run(fnc ...func())

Run functions in routine and add wait group.

Jump to

Keyboard shortcuts

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