Browse Source

feedback tweaks

pull/3878/head
Sean Braithwaite 5 years ago
parent
commit
c62b7fbd7e
2 changed files with 7 additions and 3 deletions
  1. +3
    -3
      blockchain/v2/routine.go
  2. +4
    -0
      blockchain/v2/routine_test.go

+ 3
- 3
blockchain/v2/routine.go View File

@ -23,12 +23,12 @@ type handleFunc = func(event Event) (Event, error)
// sent events and produce `last()` event representing the terminal state.
type Routine struct {
name string
handle handleFunc
queue *queue.PriorityQueue
out chan Event // XXX: actually item
out chan Event
fin chan error
rdy chan struct{}
running *uint32
handle handleFunc
logger log.Logger
metrics *Metrics
}
@ -38,8 +38,8 @@ var queueSize int = 10
func newRoutine(name string, handleFunc handleFunc) *Routine {
return &Routine{
name: name,
queue: queue.NewPriorityQueue(queueSize, true),
handle: handleFunc,
queue: queue.NewPriorityQueue(queueSize, true),
out: make(chan Event, queueSize),
rdy: make(chan struct{}, 1),
fin: make(chan error, 1),


+ 4
- 0
blockchain/v2/routine_test.go View File

@ -143,8 +143,12 @@ func TestPriority(t *testing.T) {
}()
time.Sleep(10 * time.Millisecond)
assert.True(t, routine.isRunning(),
"expected an started routine")
assert.True(t, routine.trySend(highPriorityEvent{}),
"expected send to succeed even when saturated")
assert.Equal(t, done, <-routine.final())
assert.False(t, routine.isRunning(),
"expected an started routine")
}

Loading…
Cancel
Save