Source File
worker.go
Belonging Package
github.com/pancsta/asyncmachine-go/examples/benchmark_grpc
package benchmark_grpcimport ()type Op intconst (Op1 Op = iota + 1Op2Op3)type Value intconst (Value1 Value = iota + 1Value2Value3)type Worker struct {ErrCount intSuccessCount intvalue ValueevListener func()}func ( *Worker) () {.CallOp(Op(rand.Intn(3) + 1))}func ( *Worker) ( func()) {l("worker", "Subscribe").evListener =}func ( *Worker) () Value {return .value}func ( *Worker) ( Op) {l("worker", "Call op: %v", )// assert the valueif .value != 0 {switch {case Op1:if .value != Value1 {.ErrCount++}.SuccessCount++case Op2:if .value != Value2 {.ErrCount++}.SuccessCount++case Op3:if .value != Value3 {.ErrCount++}.SuccessCount++default:// err.ErrCount++}}// create a rand value.value = Value(rand.Intn(3) + 1)// call an event.notify()}func ( *Worker) () {l("worker", "Notify").evListener()}func l(, string, ...any) {if os.Getenv("BENCH_DEBUG") == "" {return}log.Printf(+": "+, ...)}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |