parallel optimization groundwork

This commit is contained in:
LPF
2026-05-10 17:27:06 +08:00
parent ce2263ac8c
commit 7b07bb270b
37 changed files with 6896 additions and 3481 deletions

View File

@@ -346,13 +346,30 @@ type mcpClient struct {
cmd *exec.Cmd
stdin io.WriteCloser
reader *bufio.Reader
stderr bytes.Buffer
stderr mcpSafeBuffer
writeMu sync.Mutex
waiters sync.Map
nextID atomic.Int64
}
type mcpSafeBuffer struct {
mu sync.Mutex
buf bytes.Buffer
}
func (b *mcpSafeBuffer) Write(p []byte) (int, error) {
b.mu.Lock()
defer b.mu.Unlock()
return b.buf.Write(p)
}
func (b *mcpSafeBuffer) String() string {
b.mu.Lock()
defer b.mu.Unlock()
return b.buf.String()
}
type mcpInbound struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id,omitempty"`