S7 safe for concurrent use: hold the bus wrappers to it under the race detector
Many goroutines' gets, puts, pages, keys and watches through one bundle's runtime channel, one process connection's state and one process reader's pictures run under the race detector; no unguarded call was found, so the tests hold the wrappers to it. Builds: design 47 H2 §782; H-A-349 DQ-3
This commit is contained in:
@@ -4,7 +4,9 @@ package process
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -199,6 +201,31 @@ func TestStatePutAndKeysOnAGrantedBucket(t *testing.T) {
|
||||
if err != nil || strings.Join(keys, ",") != "a,b" {
|
||||
t.Fatalf("Keys: %v, %v, want a,b", keys, err)
|
||||
}
|
||||
// Design 47 H2 §782: one connection's state calls are safe at once: gets, puts, keys and watches from many goroutines
|
||||
// through the one handle, under the race detector.
|
||||
var wg sync.WaitGroup
|
||||
errs := make(chan error, 16*4)
|
||||
for i := range 16 {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
key := fmt.Sprintf("c%d", i)
|
||||
_, err := s.Put(key, i)
|
||||
errs <- err
|
||||
_, err = s.Get(key)
|
||||
errs <- err
|
||||
_, err = s.Keys()
|
||||
errs <- err
|
||||
errs <- s.Watch(key, func(stdio.StateChange) error { return nil })
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
close(errs)
|
||||
for err := range errs {
|
||||
if err != nil {
|
||||
t.Fatalf("a concurrent state call: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 1840/S2: given a process connection granted its bucket, which already holds two keys and a deleted one,
|
||||
|
||||
Reference in New Issue
Block a user