From 593c1288bc2e775cc5d116cb861141b752119d56 Mon Sep 17 00:00:00 2001 From: nytpu Date: Wed, 17 Mar 2021 11:23:44 -0600 Subject: [PATCH] resolve XXX question introduced by e42ebd8 --- core/structs.go | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/core/structs.go b/core/structs.go index a111841..abebed0 100644 --- a/core/structs.go +++ b/core/structs.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later // For more license details, see LICENSE or . -// This file incorporates code from makeworlds's amfora: +// This file incorporates code from makeworld's amfora: // https://github.com/makeworld-the-better-one/amfora/blob/master/subscriptions/structs.go // Original source is Copyright 2020 makeworld and is licensed under the // terms of the GNU General Public License Version 3.0. @@ -20,14 +20,14 @@ import ( "github.com/mmcdole/gofeed" ) -// jsonData is used for both reading from json and for storing the global feeds +// FullData is used for both reading from json and for storing the global feeds // map. contains read mutexes so concurrency can be used. -type JsonData struct { +type FullData struct { Feeds map[url.URL]*Feed `json:"feeds,omitempty"` Pages map[url.URL]*Page `json:"pages,omitempty"` - feedsMu *sync.RWMutex - pagesMu *sync.RWMutex + FeedsMu *sync.RWMutex + PagesMu *sync.RWMutex } // Feed holds all the necessary fields when storing a feed @@ -110,34 +110,6 @@ func (f *Feed) Swap(i, j int) { f.Items[i], f.Items[j] = f.Items[j], f.Items[i] } -// XXX: do both feedsMu and pagesMu need to be (un)locked together or can they -// be locked individually? they are in the same struct but they're different -// elements so they shuld be able to be accessed at the same time, right? - -// 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 {