package
module
Version:
v1.0.0
Opens a new window with list of versions in this module.
Published: May 5, 2020
License: GPL-3.0
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 3
Opens a new window with list of known importers.
README
¶
Script helps to pause goroutins synchronously
Usage
package main
import(
composer "github.com/leprosus/golang-composer"
"fmt"
"time"
"os"
)
func main() {
for i := 1; i <= 3; i++ {
go loop(i)
}
fmt.Println("All of goroutins are started")
time.Sleep(5 * time.Second)
composer.GetComposer().Pause()
fmt.Println("All of goroutins are paused")
time.Sleep(5 * time.Second)
composer.GetComposer().Play()
fmt.Println("All of goroutins are resumed")
time.Sleep(5 * time.Second)
}
func loop(id int){
for {
fmt.Printf("Goroutin #%d\n", id)
time.Sleep(time.Second)
composer.GetComposer().NeedWait()
}
}
List all methods
- composer.GetComposer - returns composer
- composer.GetComposer.Play - lets to execute goroutins
- composer.GetComposer.Pause - lets to pause goroutins execution
- composer.GetComposer.NeedWait - if need to pause then wait resuming rather do nothing
Documentation
¶
func GetComposer() *composer
Source Files
¶
Click to show internal directories.
Click to hide internal directories.