MCPcopy Index your code
hub / github.com/modern-go/concurrent

github.com/modern-go/concurrent @1.0.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.0.3 ↗ · + Follow
20 symbols 40 edges 7 files 14 documented · 70% 657 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

concurrent

Sourcegraph GoDoc Build Status codecov rcard 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

m := concurrent.NewMap()
m.Store("hello", "world")
elem, found := m.Load("hello")
// elem will be "world"
// found will be true

concurrent.Executor

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

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 8
Method 8
Struct 3
Interface 1

Languages

Go100%

Modules by API surface

unbounded_executor.go7 symbols
unbounded_executor_test.go4 symbols
go_below_19.go4 symbols
go_above_19.go2 symbols
executor.go2 symbols
map_test.go1 symbols

For agents

$ claude mcp add concurrent \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page