Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY committed Oct 30, 2024
1 parent 898493b commit 8b7c7b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions loader/register_tango.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ var pluginsMu sync.Mutex
func registerModule(mod *moduledata) {
pluginsMu.Lock()
defer pluginsMu.Unlock()
lastmoduledatap.next = mod
lastmoduledatap = mod
}
15 changes: 6 additions & 9 deletions loader/register_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build !bytedance_tango

/*
* Copyright 2023 ByteDance Inc.
*
Expand All @@ -23,25 +21,24 @@ import (
"sync"
)

func Test_registerModuleLockFree(t *testing.T) {
n, parallel := 1000, 8
head := moduledata{}
tail := &head
func Test_registerModuleRace(t *testing.T) {
n, parallel := 100, 8
s := &moduledata{}
registerModule(s)
wg := sync.WaitGroup{}
wg.Add(parallel)
filler := func(n int) {
defer wg.Done()
for i := 0; i < n; i++ {
m := &moduledata{}
registerModuleLockFree(&tail, m)
registerModule(&moduledata{})
}
}
for i := 0; i < parallel; i++ {
go filler(n)
}
wg.Wait()
i := 0
for p := head.next; p != nil; p = p.next {
for p := s.next; p != nil; p = p.next {
i += 1
}
if i != parallel * n {
Expand Down

0 comments on commit 8b7c7b6

Please sign in to comment.