2023-12-14 16:08:59 +08:00
|
|
|
// Package easymap ...
|
|
|
|
//
|
|
|
|
// Description : easymap ...
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 2023-12-14 15:51
|
|
|
|
package easymap
|
|
|
|
|
2023-12-24 22:10:47 +08:00
|
|
|
import "sync"
|
2023-12-14 16:08:59 +08:00
|
|
|
|
2023-12-24 22:10:47 +08:00
|
|
|
// common 公共基础结构
|
2023-12-14 16:08:59 +08:00
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
2023-12-24 22:10:47 +08:00
|
|
|
// Date : 15:52 2023/12/14
|
|
|
|
type common struct {
|
|
|
|
lock *sync.RWMutex // 数据锁
|
|
|
|
}
|
2023-12-14 16:08:59 +08:00
|
|
|
|
2023-12-24 22:10:47 +08:00
|
|
|
// initLock ...
|
2023-12-14 16:08:59 +08:00
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
2023-12-24 22:10:47 +08:00
|
|
|
// Date : 21:25 2023/12/24
|
|
|
|
func (c *common) initLock() {
|
|
|
|
c.lock = &sync.RWMutex{}
|
2023-12-14 16:08:59 +08:00
|
|
|
}
|
|
|
|
|
2023-12-24 22:10:47 +08:00
|
|
|
// Lock ...
|
2023-12-14 16:08:59 +08:00
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
2023-12-24 22:10:47 +08:00
|
|
|
// Date : 21:27 2023/12/24
|
|
|
|
func (c *common) Lock() {
|
|
|
|
if nil == c.lock {
|
|
|
|
|
2023-12-14 16:08:59 +08:00
|
|
|
}
|
2023-12-24 22:10:47 +08:00
|
|
|
c.lock.Lock()
|
2023-12-14 16:08:59 +08:00
|
|
|
}
|
|
|
|
|
2023-12-24 22:10:47 +08:00
|
|
|
// Unlock ...
|
2023-12-14 16:08:59 +08:00
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
2023-12-24 22:10:47 +08:00
|
|
|
// Date : 21:27 2023/12/24
|
|
|
|
func (c *common) Unlock() {
|
|
|
|
c.lock.Unlock()
|
|
|
|
}
|
|
|
|
|
|
|
|
// RLock ...
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 21:43 2023/12/24
|
|
|
|
func (c *common) RLock() {
|
|
|
|
c.lock.RLock()
|
|
|
|
}
|
|
|
|
|
|
|
|
// RUnlock ...
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 21:43 2023/12/24
|
|
|
|
func (c *common) RUnlock() {
|
|
|
|
c.lock.RUnlock()
|
2023-12-14 16:08:59 +08:00
|
|
|
}
|