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-dms3-provider
Commits
74884fbe
Commit
74884fbe
authored
Mar 16, 2019
by
Erik Ingenito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't do extra work in provider queue loop
License: MIT Signed-off-by:
Erik Ingenito
<
erik@carbonfive.com
>
parent
25a24e57
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
queue.go
queue.go
+13
-7
No files found.
queue.go
View file @
74884fbe
...
...
@@ -2,13 +2,14 @@ package provider
import
(
"context"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/namespace"
"github.com/ipfs/go-datastore/query"
"math"
"strconv"
"strings"
cid
"github.com/ipfs/go-cid"
datastore
"github.com/ipfs/go-datastore"
namespace
"github.com/ipfs/go-datastore/namespace"
query
"github.com/ipfs/go-datastore/query"
)
// Queue provides a durable, FIFO interface to the datastore for storing cids
...
...
@@ -100,11 +101,16 @@ func (q *Queue) nextEntry() (datastore.Key, cid.Cid) {
// Run dequeues and enqueues when available.
func
(
q
*
Queue
)
work
()
{
go
func
()
{
var
k
datastore
.
Key
=
datastore
.
Key
{}
var
c
cid
.
Cid
=
cid
.
Undef
for
{
k
,
c
:=
q
.
nextEntry
()
var
dequeue
chan
cid
.
Cid
if
c
==
cid
.
Undef
{
k
,
c
=
q
.
nextEntry
()
}
// If c != cid.Undef set dequeue and attempt write, otherwise wait for enqueue
var
dequeue
chan
cid
.
Cid
if
c
!=
cid
.
Undef
{
dequeue
=
q
.
dequeue
}
...
...
@@ -126,7 +132,7 @@ func (q *Queue) work() {
log
.
Errorf
(
"Failed to delete queued cid %s with key %s: %s"
,
c
,
k
,
err
)
continue
}
c
=
cid
.
Undef
q
.
head
++
case
<-
q
.
ctx
.
Done
()
:
return
...
...
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