sync.Once concurrent map iteration and map write map并发读写

 

var AMap AMapS
var once sync.Once

func confCV(r *bizRepo) {
	// TODO
	once.Do(func() {
		b := r.data.confTODOBootstrap.DomainSonypathoid
		json.Unmarshal(b, &AMap)
		r.log.Info("once")
	})
	// r.log.Info("once-skip")
}

  浅谈Golang两种线程安全的map https://mp.weixin.qq.com/s?src=11&timestamp=1643074552&ver=3579&signature=EHO-xKveIa2LEvqR8stnrI2Xr6B0*9Cl*UBvCNt4I*uUIKISDYbciZC-1djZMFl4h7Q2JVgSBpDg9oSV8MNWTax36krBNy0y6KKm1Csm1efhswDMWvBCTbIfg6bh*u5p&new=1

 

深入理解并发安全的 sync.Map https://mp.weixin.qq.com/s?src=11&timestamp=1643074552&ver=3579&signature=ZuwoVLg9tR-60kmFPaFyq9Xfc1PcSbrTSNHJIK2uLJp7Qw9kqJ3bKM6t6VjhyjTK2DQ-WpSk2wNrRkyBdlIrP1jeaK9hIDCk362xHKV15hpXYVs*H9FZv6F9v-F5KDOb&new=1

 

posted @ 2022-01-21 18:22  papering  阅读(132)  评论(0编辑  收藏  举报