ochan

Package ochan provides ordered chan.

MIT License

Stars
4

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

Package Rankings
Top 8.17% on Proxy.golang.org
Badges
Extracted from project README
Actions Status GoDoc Reference Go Report Card