Commit f5336787 authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

avoid attaching context to object when it's not necessary.

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent f028c44f
...@@ -27,7 +27,6 @@ type LedgerManager struct { ...@@ -27,7 +27,6 @@ type LedgerManager struct {
tasklist *TaskList tasklist *TaskList
taskOut chan *Task taskOut chan *Task
workSignal chan struct{} workSignal chan struct{}
ctx context.Context
} }
func NewLedgerManager(bs bstore.Blockstore, ctx context.Context) *LedgerManager { func NewLedgerManager(bs bstore.Blockstore, ctx context.Context) *LedgerManager {
...@@ -37,20 +36,19 @@ func NewLedgerManager(bs bstore.Blockstore, ctx context.Context) *LedgerManager ...@@ -37,20 +36,19 @@ func NewLedgerManager(bs bstore.Blockstore, ctx context.Context) *LedgerManager
tasklist: NewTaskList(), tasklist: NewTaskList(),
taskOut: make(chan *Task, 4), taskOut: make(chan *Task, 4),
workSignal: make(chan struct{}), workSignal: make(chan struct{}),
ctx: ctx,
} }
go lm.taskWorker() go lm.taskWorker(ctx)
return lm return lm
} }
func (lm *LedgerManager) taskWorker() { func (lm *LedgerManager) taskWorker(ctx context.Context) {
for { for {
nextTask := lm.tasklist.Pop() nextTask := lm.tasklist.Pop()
if nextTask == nil { if nextTask == nil {
// No tasks in the list? // No tasks in the list?
// Wait until there are! // Wait until there are!
select { select {
case <-lm.ctx.Done(): case <-ctx.Done():
return return
case <-lm.workSignal: case <-lm.workSignal:
} }
...@@ -58,7 +56,7 @@ func (lm *LedgerManager) taskWorker() { ...@@ -58,7 +56,7 @@ func (lm *LedgerManager) taskWorker() {
} }
select { select {
case <-lm.ctx.Done(): case <-ctx.Done():
return return
case lm.taskOut <- nextTask: case lm.taskOut <- nextTask:
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment