-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathsync_mutex_legacy.go
More file actions
68 lines (52 loc) · 1.29 KB
/
Copy pathsync_mutex_legacy.go
File metadata and controls
68 lines (52 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//go:build !goexperiment.synctest && !deadlock_synctest && !deadlock_disable && !go1.18
// +build !goexperiment.synctest,!deadlock_synctest,!deadlock_disable,!go1.18
package deadlock
import "sync"
// StandardMutex wraps sync.Mutex
type StandardMutex struct {
mu sync.Mutex
}
func (m *StandardMutex) Lock() {
m.mu.Lock()
}
func (m *StandardMutex) Unlock() {
m.mu.Unlock()
}
func (m *StandardMutex) TryLock() bool {
// TryLock is not available before Go 1.18
panic("TryLock requires Go 1.18 or later")
}
// StandardRWMutex wraps sync.RWMutex
type StandardRWMutex struct {
mu sync.RWMutex
}
func (m *StandardRWMutex) Lock() {
m.mu.Lock()
}
func (m *StandardRWMutex) Unlock() {
m.mu.Unlock()
}
func (m *StandardRWMutex) RLock() {
m.mu.RLock()
}
func (m *StandardRWMutex) RUnlock() {
m.mu.RUnlock()
}
func (m *StandardRWMutex) TryLock() bool {
// TryLock is not available before Go 1.18
panic("TryLock requires Go 1.18 or later")
}
func (m *StandardRWMutex) TryRLock() bool {
// TryRLock is not available before Go 1.18
panic("TryRLock requires Go 1.18 or later")
}
func (m *StandardRWMutex) RLocker() sync.Locker {
return m.mu.RLocker()
}
// Default factory functions
func newStandardMutex() MutexImpl {
return &StandardMutex{}
}
func newStandardRWMutex() RWMutexImpl {
return &StandardRWMutex{}
}