package release import "sync" var ( sharedMu sync.Mutex sharedRatchets = map[string]*DigestRatchet{} ) // SharedDigestRatchet is the process's one ratchet for marks written under // own (Astra I2 #1): every pass, materialization, held stage and static read // in this process gets the same object, so a channel remembered after a mark // could not be persisted stays remembered. require, once on, stays on. func SharedDigestRatchet(own string, also []string, require bool) *DigestRatchet { sharedMu.Lock() defer sharedMu.Unlock() r, ok := sharedRatchets[own] if !ok { r = NewDigestRatchet(own, also, require) sharedRatchets[own] = r return r } if require { r.require.Store(true) // atomic: Admit may be reading it right now (Astra I3 #7) } return r }