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
b5bdef70
Commit
b5bdef70
authored
Jul 15, 2014
by
Daniel Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #470 from GoogleCloudPlatform/revert-458-close_chan
Revert "Changed op.notify<-true to close(op.notify)."
parents
e659688f
61917a06
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
operation.go
pkg/apiserver/operation.go
+6
-3
No files found.
pkg/apiserver/operation.go
View file @
b5bdef70
...
@@ -34,7 +34,7 @@ type Operation struct {
...
@@ -34,7 +34,7 @@ type Operation struct {
awaiting
<-
chan
interface
{}
awaiting
<-
chan
interface
{}
finished
*
time
.
Time
finished
*
time
.
Time
lock
sync
.
Mutex
lock
sync
.
Mutex
notify
chan
struct
{}
notify
chan
bool
}
}
// Operations tracks all the ongoing operations.
// Operations tracks all the ongoing operations.
...
@@ -62,7 +62,7 @@ func (ops *Operations) NewOperation(from <-chan interface{}) *Operation {
...
@@ -62,7 +62,7 @@ func (ops *Operations) NewOperation(from <-chan interface{}) *Operation {
op
:=
&
Operation
{
op
:=
&
Operation
{
ID
:
strconv
.
FormatInt
(
id
,
10
),
ID
:
strconv
.
FormatInt
(
id
,
10
),
awaiting
:
from
,
awaiting
:
from
,
notify
:
make
(
chan
struct
{}
),
notify
:
make
(
chan
bool
,
1
),
}
}
go
op
.
wait
()
go
op
.
wait
()
go
ops
.
insert
(
op
)
go
ops
.
insert
(
op
)
...
@@ -128,7 +128,7 @@ func (op *Operation) wait() {
...
@@ -128,7 +128,7 @@ func (op *Operation) wait() {
op
.
result
=
result
op
.
result
=
result
finished
:=
time
.
Now
()
finished
:=
time
.
Now
()
op
.
finished
=
&
finished
op
.
finished
=
&
finished
close
(
op
.
notify
)
op
.
notify
<-
true
}
}
// WaitFor waits for the specified duration, or until the operation finishes,
// WaitFor waits for the specified duration, or until the operation finishes,
...
@@ -137,6 +137,9 @@ func (op *Operation) WaitFor(timeout time.Duration) {
...
@@ -137,6 +137,9 @@ func (op *Operation) WaitFor(timeout time.Duration) {
select
{
select
{
case
<-
time
.
After
(
timeout
)
:
case
<-
time
.
After
(
timeout
)
:
case
<-
op
.
notify
:
case
<-
op
.
notify
:
// Re-send on this channel in case there are others
// waiting for notification.
op
.
notify
<-
true
}
}
}
}
...
...
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