- merged type servicemgr
authorjw_wonny.cha <jw_wonny.cha@samsung.com>
Tue, 2 Apr 2019 10:07:08 +0000 (19:07 +0900)
committerjw_wonny.cha <jw_wonny.cha@samsung.com>
Tue, 2 Apr 2019 10:07:08 +0000 (19:07 +0900)
src/servicemgr/types.go
src/servicemgr/types_concurrent_map.go [deleted file]

index e0867ee84526684e856e69692042f8834d26e608..2e7edde38ec49a8ebcf821ad5ec1ab99f7301039 100644 (file)
@@ -1,5 +1,7 @@
 package servicemgr
 
+import "sync"
+
 var logPrefix = "servicemgr"
 
 // ServiceParam structrue
@@ -42,3 +44,57 @@ type StatusNotification struct {
        ServiceID uint64 `json:"ServiceID"`
        Status    string `json:"Status"`
 }
+
+type ConcurrentMap struct {
+       sync.RWMutex
+       items map[uint64]interface{}
+}
+
+// ConcurrentMapItem type
+type ConcurrentMapItem struct {
+       Key   uint64
+       Value interface{}
+}
+
+// Set is for setting map item
+func (cm *ConcurrentMap) Set(key uint64, value interface{}) {
+       cm.Lock()
+       defer cm.Unlock()
+
+       cm.items[key] = value
+}
+
+// Get is for getting map item
+func (cm *ConcurrentMap) Get(key uint64) (interface{}, bool) {
+       cm.Lock()
+       defer cm.Unlock()
+
+       value, ok := cm.items[key]
+
+       return value, ok
+}
+
+// Remove is for removing map item
+func (cm *ConcurrentMap) Remove(key uint64) {
+       cm.Lock()
+       defer cm.Unlock()
+
+       delete(cm.items, key)
+}
+
+// Iter is for iterating map item
+func (cm *ConcurrentMap) Iter() <-chan ConcurrentMapItem {
+       c := make(chan ConcurrentMapItem)
+
+       go func() {
+               cm.Lock()
+               defer cm.Unlock()
+
+               for k, v := range cm.items {
+                       c <- ConcurrentMapItem{k, v}
+               }
+               close(c)
+       }()
+
+       return c
+}
diff --git a/src/servicemgr/types_concurrent_map.go b/src/servicemgr/types_concurrent_map.go
deleted file mode 100644 (file)
index 4bc2a19..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-package servicemgr
-
-import "sync"
-
-// ConcurrentMap type
-type ConcurrentMap struct {
-       sync.RWMutex
-       items map[uint64]interface{}
-}
-
-// ConcurrentMapItem type
-type ConcurrentMapItem struct {
-       Key   uint64
-       Value interface{}
-}
-
-// Set is for setting map item
-func (cm *ConcurrentMap) Set(key uint64, value interface{}) {
-       cm.Lock()
-       defer cm.Unlock()
-
-       cm.items[key] = value
-}
-
-// Get is for getting map item
-func (cm *ConcurrentMap) Get(key uint64) (interface{}, bool) {
-       cm.Lock()
-       defer cm.Unlock()
-
-       value, ok := cm.items[key]
-
-       return value, ok
-}
-
-// Remove is for removing map item
-func (cm *ConcurrentMap) Remove(key uint64) {
-       cm.Lock()
-       defer cm.Unlock()
-
-       delete(cm.items, key)
-}
-
-// Iter is for iterating map item
-func (cm *ConcurrentMap) Iter() <-chan ConcurrentMapItem {
-       c := make(chan ConcurrentMapItem)
-
-       f := func() {
-               cm.Lock()
-               defer cm.Unlock()
-
-               for k, v := range cm.items {
-                       c <- ConcurrentMapItem{k, v}
-               }
-               close(c)
-       }
-       go f()
-
-       return c
-}