Files
zeekay 021a8edace fix: resolve proto import paths and test compilation issues
- Fix dag package imports to use vm/proto/pb/dag instead of node/proto
- Fix api/health test to use atomic.Atomic from github.com/luxfi/atomic
- Fix components/message test to use crypto.RandomBytes
- Fix chains/manager to use correct EngineType constant
2026-01-11 20:58:38 -08:00

48 lines
844 B
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package runtime
import (
"context"
"sync"
)
// Manages tracking and shutdown of VM runtimes.
type manager struct {
lock sync.Mutex
runtimes []Stopper
}
// NewManager returns manager of VM runtimes.
//
// to remove it from the current set.
func NewManager() Manager {
return &manager{}
}
func (m *manager) Stop(ctx context.Context) {
var wg sync.WaitGroup
m.lock.Lock()
defer func() {
m.lock.Unlock()
wg.Wait()
}()
wg.Add(len(m.runtimes))
for _, rt := range m.runtimes {
go func(runtime Stopper) {
defer wg.Done()
runtime.Stop(ctx)
}(rt)
}
m.runtimes = nil
}
func (m *manager) TrackRuntime(runtime Stopper) {
m.lock.Lock()
defer m.lock.Unlock()
m.runtimes = append(m.runtimes, runtime)
}