Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
1ca99119
Commit
1ca99119
authored
Aug 02, 2016
by
Matt T. Proud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pkg/controller/garbagecollector: simplify mutexes.
Similar to #29598, we can rely on the zero-value construction behavior to embed `sync.Mutex` into parent structs.
parent
37d3d390
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
7 deletions
+5
-7
garbagecollector.go
pkg/controller/garbagecollector/garbagecollector.go
+4
-6
garbagecollector_test.go
pkg/controller/garbagecollector/garbagecollector_test.go
+1
-1
No files found.
pkg/controller/garbagecollector/garbagecollector.go
View file @
1ca99119
...
...
@@ -67,7 +67,7 @@ func (s objectReference) String() string {
type
node
struct
{
identity
objectReference
// dependents will be read by the orphan() routine, we need to protect it with a lock.
dependentsLock
*
sync
.
RWMutex
dependentsLock
sync
.
RWMutex
dependents
map
[
*
node
]
struct
{}
// When processing an Update event, we need to compare the updated
// ownerReferences with the owners recorded in the graph.
...
...
@@ -151,8 +151,7 @@ func (p *Propagator) addDependentToOwners(n *node, owners []metatypes.OwnerRefer
OwnerReference
:
owner
,
Namespace
:
n
.
identity
.
Namespace
,
},
dependentsLock
:
&
sync
.
RWMutex
{},
dependents
:
make
(
map
[
*
node
]
struct
{}),
dependents
:
make
(
map
[
*
node
]
struct
{}),
}
p
.
uidToNode
.
Write
(
ownerNode
)
p
.
gc
.
dirtyQueue
.
Add
(
ownerNode
)
...
...
@@ -378,9 +377,8 @@ func (p *Propagator) processEvent() {
},
Namespace
:
accessor
.
GetNamespace
(),
},
dependentsLock
:
&
sync
.
RWMutex
{},
dependents
:
make
(
map
[
*
node
]
struct
{}),
owners
:
accessor
.
GetOwnerReferences
(),
dependents
:
make
(
map
[
*
node
]
struct
{}),
owners
:
accessor
.
GetOwnerReferences
(),
}
p
.
insertNode
(
newNode
)
// the underlying delta_fifo may combine a creation and deletion into one event
...
...
pkg/controller/garbagecollector/garbagecollector_test.go
View file @
1ca99119
...
...
@@ -301,7 +301,7 @@ func TestDependentsRace(t *testing.T) {
}
const
updates
=
100
owner
:=
&
node
{
dependents
Lock
:
&
sync
.
RWMutex
{},
dependents
:
make
(
map
[
*
node
]
struct
{})}
owner
:=
&
node
{
dependents
:
make
(
map
[
*
node
]
struct
{})}
ownerUID
:=
types
.
UID
(
"owner"
)
gc
.
propagator
.
uidToNode
.
Write
(
owner
)
go
func
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment