mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-07 20:47:45 +00:00
Fix Go 1.19 compatibility issue.
This commit is contained in:
@@ -154,6 +154,11 @@ func First[K comparable, V any](m Map[K, V]) Pair[K, V] {
|
|||||||
return m.First()
|
return m.First()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type jobStatus[T any] struct {
|
||||||
|
done chan struct{}
|
||||||
|
result T
|
||||||
|
}
|
||||||
|
|
||||||
// TranslateMapParallel iterates a `Map` in parallel and calls translate()
|
// TranslateMapParallel iterates a `Map` in parallel and calls translate()
|
||||||
// asynchronously.
|
// asynchronously.
|
||||||
// translate() or result() may return `io.EOF` to break iteration.
|
// translate() or result() may return `io.EOF` to break iteration.
|
||||||
@@ -164,16 +169,11 @@ func TranslateMapParallel[K comparable, V any, RV any](m Map[K, V], translate Tr
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type jobStatus struct {
|
|
||||||
done chan struct{}
|
|
||||||
result RV
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
concurrency := runtime.NumCPU()
|
concurrency := runtime.NumCPU()
|
||||||
c := Iterate(ctx, m)
|
c := Iterate(ctx, m)
|
||||||
jobChan := make(chan *jobStatus, concurrency)
|
jobChan := make(chan *jobStatus[RV], concurrency)
|
||||||
var reterr error
|
var reterr error
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
var mu sync.Mutex
|
var mu sync.Mutex
|
||||||
@@ -186,7 +186,7 @@ func TranslateMapParallel[K comparable, V any, RV any](m Map[K, V], translate Tr
|
|||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
for pair := range c {
|
for pair := range c {
|
||||||
j := &jobStatus{
|
j := &jobStatus[RV]{
|
||||||
done: make(chan struct{}),
|
done: make(chan struct{}),
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
|
|||||||
Reference in New Issue
Block a user