Skip to content

sago35/ochan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Actions Status GoDoc Reference Go Report Card

Ochan

Package ochan provides ordered chan.

Usage

Package ochan supports generics.
Thus, it can work with any type by supplying chan T to NewOchan().
See ochan_test.go for an example of its use.

func ExampleOchan() {
	result := make(chan string, 100)
	o := NewOchan(result, 100)

	c1 := o.GetCh()
	c2 := o.GetCh()

	c1 <- "Hello c1"
	c2 <- "Hello c2"
	c1 <- "Bye c1"
	c2 <- "Bye c2"

	close(c1)
	close(c2)

	o.Wait()
	close(result)

	for s := range result {
		fmt.Println(s)
		// Output:
		// Hello c1
		// Bye c1
		// Hello c2
		// Bye c2
	}
}

Licence

MIT

About

Package ochan provides ordered chan.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages