You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, let me say that this is amazing work correcting 100 Golang code mistakes while writing clean code. Thank you for your hard work. I am learning a lot.
Second, it is not an issue just an observation - wouldn't semaphores be the best solution for making concurrency more productive? The solution is to teach the best there is to teach about Golang right?
`const max = 2048 // Defines the threshold
func parallelMergesortV2(s []int) {
if len(s) <= 1 {
return
}
if len(s) <= max {
sequentialMergesort(s) // Calls our initial sequential version
} else { // If bigger than the threshold, keeps the parallel version
middle := len(s) / 2
var wg sync.WaitGroup
wg.Add(2)
go func() {
defer wg.Done()
parallelMergesortV2(s[:middle])
}()
go func() {
defer wg.Done()
parallelMergesortV2(s[middle:])
}()
wg.Wait()
merge(s, middle)
}
}`
Solution
I would recommend the use of semaphores
One or multiple solutions to avoid the mistake.
The text was updated successfully, but these errors were encountered:
Use of Semaphores
First of all, let me say that this is amazing work correcting 100 Golang code mistakes while writing clean code. Thank you for your hard work. I am learning a lot.
Second, it is not an issue just an observation - wouldn't semaphores be the best solution for making concurrency more productive? The solution is to teach the best there is to teach about Golang right?
`const max = 2048 // Defines the threshold
func parallelMergesortV2(s []int) {
}`
Solution
I would recommend the use of semaphores
One or multiple solutions to avoid the mistake.
The text was updated successfully, but these errors were encountered: