New Upstream Snapshot - golang-github-jacobsa-syncutil
Ready changes
Summary
Merged new upstream version: 0.0~git20180202 (was: 0.0~git20150615).
Resulting package
Built on 2022-10-28T10:46 (took 4m15s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-snapshots golang-github-jacobsa-syncutil-dev
Lintian Result
Diff
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..daf913b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,24 @@
+# Compiled Object files, Static and Dynamic libs (Shared Objects)
+*.o
+*.a
+*.so
+
+# Folders
+_obj
+_test
+
+# Architecture specific extensions/prefixes
+*.[568vq]
+[568vq].out
+
+*.cgo1.go
+*.cgo2.c
+_cgo_defun.c
+_cgo_gotypes.go
+_cgo_export.*
+
+_testmain.go
+
+*.exe
+*.test
+*.prof
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..b972119
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+# Cf. http://docs.travis-ci.com/user/getting-started/
+# Cf. http://docs.travis-ci.com/user/languages/go/
+
+language: go
diff --git a/debian/changelog b/debian/changelog
index b288c69..0af9a74 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,12 @@
-golang-github-jacobsa-syncutil (0.0~git20150615-4) UNRELEASED; urgency=medium
+golang-github-jacobsa-syncutil (0.0~git20180202-1) UNRELEASED; urgency=medium
+ [ Alexandre Viau ]
* Point Vcs-* urls to salsa.debian.org.
- -- Alexandre Viau <aviau@debian.org> Mon, 02 Apr 2018 18:06:05 -0400
+ [ Debian Janitor ]
+ * New upstream snapshot.
+
+ -- Alexandre Viau <aviau@debian.org> Fri, 28 Oct 2022 10:42:59 -0000
golang-github-jacobsa-syncutil (0.0~git20150615-3) unstable; urgency=medium
diff --git a/invariant_mutex.go b/invariant_mutex.go
index 70ec87e..562e12f 100644
--- a/invariant_mutex.go
+++ b/invariant_mutex.go
@@ -15,11 +15,21 @@
package syncutil
import (
- "flag"
"sync"
+ "sync/atomic"
)
-var fCheckInvariants = flag.Bool("syncutil.check_invariants", false, "Crash when registered invariants are violated.")
+var gEnable uintptr
+
+// Enable checking of invariants when locking and unlocking InvariantMutex.
+func EnableInvariantChecking() {
+ atomic.StoreUintptr(&gEnable, 1)
+}
+
+// Has EnableInvariantChecking previously been called?
+func InvariantCheckingEnabled() bool {
+ return atomic.LoadUintptr(&gEnable) != 0
+}
// A sync.Locker that, when enabled, runs a check for registered invariants at
// times when invariants should hold. This can aid debugging subtle code by
@@ -56,8 +66,8 @@ var fCheckInvariants = flag.Bool("syncutil.check_invariants", false, "Crash when
// }
// }
//
-// // When the flag is set, invariants will be checked at entry to and exit
-// // from this function.
+// // When EnableInvariantChecking has been called, invariants will be
+// // checked at entry to and exit from this function.
// func (s *myStruct) setGeneration(n int) {
// s.mu.Lock()
// defer s.mu.Unlock()
@@ -67,7 +77,7 @@ var fCheckInvariants = flag.Bool("syncutil.check_invariants", false, "Crash when
// }
//
type InvariantMutex struct {
- mu sync.Mutex
+ mu sync.RWMutex
check func()
}
@@ -81,30 +91,36 @@ func (i *InvariantMutex) Unlock() {
i.mu.Unlock()
}
+func (i *InvariantMutex) RLock() {
+ i.mu.RLock()
+ i.checkIfEnabled()
+}
+
+func (i *InvariantMutex) RUnlock() {
+ i.checkIfEnabled()
+ i.mu.RUnlock()
+}
+
func (i *InvariantMutex) checkIfEnabled() {
- if *fCheckInvariants {
+ if InvariantCheckingEnabled() {
i.check()
}
}
-// Create a lock which, when the flag --syncutil.check_invariants is set, will
-// call the supplied function at moments when invariants protected by the lock
+// Create a lock which, when EnableInvariantChecking has been called, will call
+// the supplied function at moments when invariants protected by the lock
// should hold (e.g. just after acquiring the lock). The function should crash
// if an invariant is violated. It should not have side effects, as there are
// no guarantees that it will run.
//
// The invariants must hold at the time that NewInvariantMutex is called.
-func NewInvariantMutex(check func()) InvariantMutex {
+func NewInvariantMutex(check func()) (mu InvariantMutex) {
if check == nil {
panic("check must be non-nil.")
}
- // Check now, if enabled.
- if *fCheckInvariants {
- check()
- }
+ mu.check = check
+ mu.checkIfEnabled()
- return InvariantMutex{
- check: check,
- }
+ return
}
Debdiff
File lists identical (after any substitutions)
No differences were encountered in the control files