From e1a5c68ec75b1cbae5b4bfb788412512c557e9ad Mon Sep 17 00:00:00 2001 From: nytpu Date: Thu, 18 Mar 2021 10:18:54 -0600 Subject: add init for global FullData --- core/structs.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'core/structs.go') diff --git a/core/structs.go b/core/structs.go index abebed0..28915e1 100644 --- a/core/structs.go +++ b/core/structs.go @@ -8,8 +8,6 @@ // terms of the GNU General Public License Version 3.0. // https://www.gnu.org/licenses/gpl-3.0-standalone.html -// package core implements the structs and other necessary resources for storing -// and managing feeds and pages package core import ( @@ -110,6 +108,30 @@ func (f *Feed) Swap(i, j int) { f.Items[i], f.Items[j] = f.Items[j], f.Items[i] } +// Lock locks both feed and page mutexes. +func (j *JsonData) Lock() { + j.FeedsMu.Lock() + j.PagesMu.Lock() +} + +// Unlock unlocks both feed and page mutexes. +func (j *JsonData) Unlock() { + j.FeedsMu.Unlock() + j.PagesMu.Unlock() +} + +// RLock read-locks both feed and page mutexes. +func (j *JsonData) RLock() { + j.FeedsMu.RLock() + j.PagesMu.RLock() +} + +// RUnlock read-unlocks both feed and page mutexes. +func (j *JsonData) RUnlock() { + j.FeedsMu.RUnlock() + j.PagesMu.RUnlock() +} + // PageEntry is a single item on a subscriptions page. It is used for both feeds // and pages. type PageEntry struct { -- cgit v1.2.3