Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/f2prateek/go-executor
https://github.com/f2prateek/go-executor
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/f2prateek/go-executor
- Owner: f2prateek
- Created: 2015-07-16T05:24:11.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-27T09:07:10.000Z (about 9 years ago)
- Last Synced: 2023-03-24T08:21:47.878Z (over 1 year ago)
- Language: Go
- Size: 137 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-executor
Experimental executor implementation for Go.
Decouples task submission from mechanics of how each task will be run.
Currently provides a single implemention via the PoolExecutor.
In this example, the pooled executor will guarantee that only upto 20 goroutines run at a given time.
```
func main() {
e := NewPooledExecutor(20)var wg sync.WaitGroup
for i := 0; i < 100; i++ {
wg.Add(1)
e.enqueue(func() {
defer wg.Done()
time.Sleep(500 * time.Millisecond)
fmt.Println("hello")
})
}wg.Wait()
}
```Easy to see that in tests you could swap the executor for a simpler implementation, such as a syncronous executor.