summaryrefslogtreecommitdiff
path: root/internal/federation/dereferencing/util.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-10-31 11:12:22 +0000
committerLibravatar GitHub <noreply@github.com>2023-10-31 11:12:22 +0000
commitce71a5a7902963538fc54583588850563f6746cc (patch)
tree3e869eba6d25d2db5fe81184ffee595e451b3147 /internal/federation/dereferencing/util.go
parent[bugfix] Relax `Mention` parsing, allowing either href or name (#2320) (diff)
downloadgotosocial-ce71a5a7902963538fc54583588850563f6746cc.tar.xz
[feature] add per-uri dereferencer locks (#2291)
Diffstat (limited to 'internal/federation/dereferencing/util.go')
-rw-r--r--internal/federation/dereferencing/util.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/federation/dereferencing/util.go b/internal/federation/dereferencing/util.go
new file mode 100644
index 000000000..e69aeec3b
--- /dev/null
+++ b/internal/federation/dereferencing/util.go
@@ -0,0 +1,29 @@
+// GoToSocial
+// Copyright (C) GoToSocial Authors admin@gotosocial.org
+// SPDX-License-Identifier: AGPL-3.0-or-later
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package dereferencing
+
+// doOnce wraps a function to only perform it once.
+func doOnce(fn func()) func() {
+ var once int32
+ return func() {
+ if once == 0 {
+ fn()
+ once = 1
+ }
+ }
+}