3 [![Sourcegraph](https://sourcegraph.com/github.com/modern-go/concurrent/-/badge.svg)](https://sourcegraph.com/github.com/modern-go/concurrent?badge)
4 [![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/modern-go/concurrent)
5 [![Build Status](https://travis-ci.org/modern-go/concurrent.svg?branch=master)](https://travis-ci.org/modern-go/concurrent)
6 [![codecov](https://codecov.io/gh/modern-go/concurrent/branch/master/graph/badge.svg)](https://codecov.io/gh/modern-go/concurrent)
7 [![rcard](https://goreportcard.com/badge/github.com/modern-go/concurrent)](https://goreportcard.com/report/github.com/modern-go/concurrent)
8 [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://raw.githubusercontent.com/modern-go/concurrent/master/LICENSE)
10 * concurrent.Map: backport sync.Map for go below 1.9
11 * concurrent.Executor: goroutine with explicit ownership and cancellable
15 because sync.Map is only available in go 1.9, we can use concurrent.Map to make code portable
18 m := concurrent.NewMap()
19 m.Store("hello", "world")
20 elem, found := m.Load("hello")
21 // elem will be "world"
28 executor := concurrent.NewUnboundedExecutor()
29 executor.Go(func(ctx context.Context) {
30 everyMillisecond := time.NewTicker(time.Millisecond)
34 fmt.Println("goroutine exited")
36 case <-everyMillisecond.C:
41 time.Sleep(time.Second)
42 executor.StopAndWaitForever()
43 fmt.Println("executor stopped")
46 attach goroutine to executor instance, so that we can
48 * cancel it by stop the executor with Stop/StopAndWait/StopAndWaitForever
49 * handle panic by callback: the default behavior will no longer crash your application