fix: small fixes in csync

This commit is contained in:
Carlos Alexandro Becker
2025-07-28 15:48:35 -03:00
parent cdb311d7ca
commit 70f899352f
2 changed files with 7 additions and 9 deletions

3
internal/csync/doc.go Normal file
View File

@@ -0,0 +1,3 @@
// Package csync provides concurrent data structures for safe access in
// multi-threaded environments.
package csync

View File

@@ -260,22 +260,17 @@ func TestSlice(t *testing.T) {
var wg sync.WaitGroup
// Concurrent appends
for i := 0; i < numGoroutines; i++ {
wg.Add(1)
for i := range numGoroutines {
wg.Add(2)
go func(start int) {
defer wg.Done()
for j := 0; j < itemsPerGoroutine; j++ {
for j := range itemsPerGoroutine {
s.Append(start*itemsPerGoroutine + j)
}
}(i)
}
// Concurrent reads
for i := 0; i < numGoroutines; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for j := 0; j < itemsPerGoroutine; j++ {
for range itemsPerGoroutine {
s.Len() // Just read the length
}
}()