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-bitswap
Commits
cc677a40
Commit
cc677a40
authored
Dec 16, 2014
by
Brian Tiger Chow
Committed by
Juan Batiz-Benet
Dec 17, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
privatize Task
License: MIT Signed-off-by:
Brian Tiger Chow
<
brian@perfmode.com
>
parent
404ac1d2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
strategy/taskqueue.go
strategy/taskqueue.go
+8
-8
No files found.
strategy/taskqueue.go
View file @
cc677a40
...
...
@@ -9,17 +9,17 @@ import (
// to help decide how to sort tasks (on add) and how to select
// tasks (on getnext). For now, we are assuming a dumb/nice strategy.
type
taskQueue
struct
{
tasks
[]
*
T
ask
taskmap
map
[
string
]
*
T
ask
tasks
[]
*
t
ask
taskmap
map
[
string
]
*
t
ask
}
func
newTaskQueue
()
*
taskQueue
{
return
&
taskQueue
{
taskmap
:
make
(
map
[
string
]
*
T
ask
),
taskmap
:
make
(
map
[
string
]
*
t
ask
),
}
}
type
T
ask
struct
{
type
t
ask
struct
{
Key
u
.
Key
Target
peer
.
Peer
theirPriority
int
...
...
@@ -30,11 +30,11 @@ type Task struct {
func
(
tl
*
taskQueue
)
Push
(
block
u
.
Key
,
priority
int
,
to
peer
.
Peer
)
{
if
task
,
ok
:=
tl
.
taskmap
[
taskKey
(
to
,
block
)];
ok
{
// TODO: when priority queue is implemented,
// rearrange this
T
ask
// rearrange this
t
ask
task
.
theirPriority
=
priority
return
}
task
:=
&
T
ask
{
task
:=
&
t
ask
{
Key
:
block
,
Target
:
to
,
theirPriority
:
priority
,
...
...
@@ -44,8 +44,8 @@ func (tl *taskQueue) Push(block u.Key, priority int, to peer.Peer) {
}
// Pop 'pops' the next task to be performed. Returns nil no task exists.
func
(
tl
*
taskQueue
)
Pop
()
*
T
ask
{
var
out
*
T
ask
func
(
tl
*
taskQueue
)
Pop
()
*
t
ask
{
var
out
*
t
ask
for
len
(
tl
.
tasks
)
>
0
{
// TODO: instead of zero, use exponential distribution
// it will help reduce the chance of receiving
...
...
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