diff options
author | Unknwon <u@gogs.io> | 2019-10-23 23:03:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-23 23:03:17 -0700 |
commit | 613139e7bef81d3573e7988a47eb6765f3de347a (patch) | |
tree | 49de7277898d3ff47a122c072568edb8ed4c9ac9 /vendor/github.com/modern-go/concurrent/README.md | |
parent | fb100dbf98f02e4c631d142ff0f52ec29ee2f00c (diff) |
Enable Go modules (#5835)
* Remove vendor
* Enable Go modules
* ci: add command to fetch dependencies
* ci: update setting
* ci: update settings
* Require Go 1.11
* Rename module name to gogs.io/gogs
Diffstat (limited to 'vendor/github.com/modern-go/concurrent/README.md')
-rw-r--r-- | vendor/github.com/modern-go/concurrent/README.md | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/vendor/github.com/modern-go/concurrent/README.md b/vendor/github.com/modern-go/concurrent/README.md deleted file mode 100644 index acab3200..00000000 --- a/vendor/github.com/modern-go/concurrent/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# concurrent - -[](https://sourcegraph.com/github.com/modern-go/concurrent?badge) -[](http://godoc.org/github.com/modern-go/concurrent) -[](https://travis-ci.org/modern-go/concurrent) -[](https://codecov.io/gh/modern-go/concurrent) -[](https://goreportcard.com/report/github.com/modern-go/concurrent) -[](https://raw.githubusercontent.com/modern-go/concurrent/master/LICENSE) - -* concurrent.Map: backport sync.Map for go below 1.9 -* concurrent.Executor: goroutine with explicit ownership and cancellable - -# concurrent.Map - -because sync.Map is only available in go 1.9, we can use concurrent.Map to make code portable - -```go -m := concurrent.NewMap() -m.Store("hello", "world") -elem, found := m.Load("hello") -// elem will be "world" -// found will be true -``` - -# concurrent.Executor - -```go -executor := concurrent.NewUnboundedExecutor() -executor.Go(func(ctx context.Context) { - everyMillisecond := time.NewTicker(time.Millisecond) - for { - select { - case <-ctx.Done(): - fmt.Println("goroutine exited") - return - case <-everyMillisecond.C: - // do something - } - } -}) -time.Sleep(time.Second) -executor.StopAndWaitForever() -fmt.Println("executor stopped") -``` - -attach goroutine to executor instance, so that we can - -* cancel it by stop the executor with Stop/StopAndWait/StopAndWaitForever -* handle panic by callback: the default behavior will no longer crash your application
\ No newline at end of file |