Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-kad-dht
Commits
bd60c95d
Commit
bd60c95d
authored
Mar 13, 2019
by
Raúl Kripalani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace atomics with sync.Once.
parent
b649bcbe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
12 deletions
+11
-12
dial_queue.go
dial_queue.go
+11
-12
No files found.
dial_queue.go
View file @
bd60c95d
...
...
@@ -4,7 +4,7 @@ import (
"context"
"fmt"
"math"
"sync
/atomic
"
"sync"
"time"
peer
"github.com/libp2p/go-libp2p-peer"
...
...
@@ -32,9 +32,9 @@ const (
type
dialQueue
struct
{
*
dqParams
nWorkers
uint
out
*
queue
.
ChanQueue
start
ed
int32
nWorkers
uint
out
*
queue
.
ChanQueue
start
Once
sync
.
Once
waitingCh
chan
waitingCh
dieCh
chan
struct
{}
...
...
@@ -128,14 +128,13 @@ func newDialQueue(params *dqParams) (*dialQueue, error) {
// Start initiates action on this dial queue. It should only be called once; subsequent calls are ignored.
func
(
dq
*
dialQueue
)
Start
()
{
if
!
atomic
.
CompareAndSwapInt32
(
&
dq
.
started
,
0
,
1
)
{
return
}
tgt
:=
int
(
dq
.
dqParams
.
config
.
minParallelism
)
for
i
:=
0
;
i
<
tgt
;
i
++
{
go
dq
.
worker
()
}
dq
.
nWorkers
=
uint
(
tgt
)
dq
.
startOnce
.
Do
(
func
()
{
tgt
:=
int
(
dq
.
dqParams
.
config
.
minParallelism
)
for
i
:=
0
;
i
<
tgt
;
i
++
{
go
dq
.
worker
()
}
dq
.
nWorkers
=
uint
(
tgt
)
})
}
func
(
dq
*
dialQueue
)
control
()
{
...
...
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