From 6b6f33ed7182fa75716e90b35b709fe25f5841e0 Mon Sep 17 00:00:00 2001
From: Pavel Karpy
Date: Thu, 20 Apr 2023 17:59:44 +0300
Subject: [PATCH] [#274] wc: Make wait groups work more explicit
Do not run routine that calls `wg.Done()` inside, it is hard to read.
Signed-off-by: Pavel Karpy
---
pkg/local_object_storage/writecache/flush.go | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/pkg/local_object_storage/writecache/flush.go b/pkg/local_object_storage/writecache/flush.go
index 9d0ffc98..04fccced 100644
--- a/pkg/local_object_storage/writecache/flush.go
+++ b/pkg/local_object_storage/writecache/flush.go
@@ -41,7 +41,10 @@ func (c *cache) runFlushLoop() {
}
c.wg.Add(1)
- go c.flushBigObjects(context.TODO())
+ go func() {
+ c.flushBigObjects(context.TODO())
+ c.wg.Done()
+ }()
c.wg.Add(1)
go func() {
@@ -146,8 +149,6 @@ func (c *cache) flushDB() {
}
func (c *cache) flushBigObjects(ctx context.Context) {
- defer c.wg.Done()
-
tick := time.NewTicker(defaultFlushInterval * 10)
for {
select {