Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer (GitLab) <jacob@gitlab.com>2018-04-06 14:50:23 +0300
committerJacob Vosmaer (GitLab) <jacob@gitlab.com>2018-04-06 14:50:23 +0300
commit796fdd9316fe755330dc37b7c51dfe652acbc9f1 (patch)
tree2157f121d62b72d1d1795e7eff08ef855b2f0802
parent18818d2fc5c6e8a2f197883b56774e57d8024a96 (diff)
Revert "Merge branch 'dont-use-atomic' into 'master'"
This reverts merge request !653
-rw-r--r--STYLE.md13
-rw-r--r--internal/middleware/limithandler/testhelper_test.go16
2 files changed, 6 insertions, 23 deletions
diff --git a/STYLE.md b/STYLE.md
index d72775073..3a6ae2bad 100644
--- a/STYLE.md
+++ b/STYLE.md
@@ -107,15 +107,4 @@ instead of:
func (server) GetBlob(_ *pb.GetBlobRequest, _ pb.BlobService_GetBlobServer) error {
return helper.Unimplemented
}
-```
-
-## Concurrency
-
-The [documentation of "sync/atomic"](https://golang.org/pkg/sync/atomic/) says:
-
-> These functions require great care to be used correctly. Except for
-special, low-level applications, synchronization is better done with
-channels or the facilities of the sync package.
-
-Gitaly is not a low-level application so we should avoid "sync/atomic".
-We use channels and [package "sync"](https://golang.org/pkg/sync/).
+``` \ No newline at end of file
diff --git a/internal/middleware/limithandler/testhelper_test.go b/internal/middleware/limithandler/testhelper_test.go
index e197b18f4..40eff4f01 100644
--- a/internal/middleware/limithandler/testhelper_test.go
+++ b/internal/middleware/limithandler/testhelper_test.go
@@ -1,29 +1,23 @@
package limithandler_test
import (
- "sync"
+ "sync/atomic"
pb "gitlab.com/gitlab-org/gitaly/internal/middleware/limithandler/testpb"
"golang.org/x/net/context"
)
type server struct {
- requestCount int
- sync.Mutex
- blockCh chan (struct{})
+ requestCount uint64
+ blockCh chan (struct{})
}
func (s *server) registerRequest() {
- s.Lock()
- s.requestCount++
- s.Unlock()
+ atomic.AddUint64(&s.requestCount, 1)
}
func (s *server) getRequestCount() int {
- s.Lock()
- count := s.requestCount
- s.Unlock()
- return count
+ return int(atomic.LoadUint64(&s.requestCount))
}
func (s *server) Unary(ctx context.Context, in *pb.UnaryRequest) (*pb.UnaryResponse, error) {