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
dms3
go-blockservice
Commits
6d19450b
Commit
6d19450b
authored
Jan 30, 2015
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refac(blockservice) extract waitable
parent
f4fbf264
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
17 deletions
+2
-17
worker/worker.go
worker/worker.go
+2
-17
No files found.
worker/worker.go
View file @
6d19450b
...
...
@@ -6,11 +6,11 @@ import (
"errors"
"time"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
process
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
ratelimit
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/ratelimit"
blocks
"github.com/jbenet/go-ipfs/blocks"
exchange
"github.com/jbenet/go-ipfs/exchange"
waitable
"github.com/jbenet/go-ipfs/thirdparty/waitable"
util
"github.com/jbenet/go-ipfs/util"
)
...
...
@@ -119,7 +119,7 @@ func (w *Worker) start(c Config) {
// reads from |workerChan| until process closes
w
.
process
.
Go
(
func
(
proc
process
.
Process
)
{
ctx
:=
child
Context
(
proc
)
// shut down in-progress HasBlock when time to die
ctx
:=
waitable
.
Context
(
proc
)
// shut down in-progress HasBlock when time to die
limiter
:=
ratelimit
.
NewRateLimiter
(
process
.
Background
(),
c
.
NumWorkers
)
defer
limiter
.
Close
()
for
{
...
...
@@ -181,18 +181,3 @@ func (s *BlockList) Pop() *blocks.Block {
func
(
s
*
BlockList
)
Len
()
int
{
return
s
.
list
.
Len
()
}
// TODO extract
type
waitable
interface
{
Closing
()
<-
chan
struct
{}
}
// TODO extract
func
childContext
(
w
waitable
)
context
.
Context
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
go
func
()
{
<-
w
.
Closing
()
cancel
()
}()
return
ctx
}
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