add some notes + intentions

This commit is contained in:
Sean Braithwaite 2019-07-31 08:10:47 +02:00
parent 2545b73804
commit ecde4df0f4
2 changed files with 28 additions and 25 deletions

View File

@ -5,6 +5,31 @@ import (
"time" "time"
) )
func schedulerHandle(event Event) Events {
switch event.(type) {
case timeCheck:
fmt.Println("scheduler handle timeCheck")
case testEvent:
fmt.Println("scheduler handle testEvent")
return Events{scTestEvent{}}
}
return Events{}
}
func processorHandle(event Event) Events {
switch event.(type) {
case timeCheck:
fmt.Println("processor handle timeCheck")
case testEvent:
fmt.Println("processor handle testEvent")
case scTestEvent:
fmt.Println("processor handle scTestEvent")
// should i stop myself?
return Events{pcFinished{}}
}
return Events{}
}
// reactor // reactor
type Reactor struct { type Reactor struct {
events chan Event events chan Event

View File

@ -34,6 +34,8 @@ func newRoutine(name string, output chan Event, handleFunc handleFunc) *Routine
} }
} }
// TODO: refactor the handle to return an second variable, error which can signal
//to the run looop when the handler is done
func (rt *Routine) run() { func (rt *Routine) run() {
fmt.Printf("%s: run\n", rt.name) fmt.Printf("%s: run\n", rt.name)
for { for {
@ -45,6 +47,7 @@ func (rt *Routine) run() {
return return
} }
oEvents := rt.handle(iEvent) oEvents := rt.handle(iEvent)
// XXX: this should check for error and exit if error
fmt.Printf("%s handled %d events\n", rt.name, len(oEvents)) fmt.Printf("%s handled %d events\n", rt.name, len(oEvents))
for _, event := range oEvents { for _, event := range oEvents {
// check for finished // check for finished
@ -108,28 +111,3 @@ func (rt *Routine) stop() {
func (rt *Routine) wait() { func (rt *Routine) wait() {
<-rt.finished <-rt.finished
} }
func schedulerHandle(event Event) Events {
switch event.(type) {
case timeCheck:
fmt.Println("scheduler handle timeCheck")
case testEvent:
fmt.Println("scheduler handle testEvent")
return Events{scTestEvent{}}
}
return Events{}
}
func processorHandle(event Event) Events {
switch event.(type) {
case timeCheck:
fmt.Println("processor handle timeCheck")
case testEvent:
fmt.Println("processor handle testEvent")
case scTestEvent:
fmt.Println("processor handle scTestEvent")
// should i stop myself?
return Events{pcFinished{}}
}
return Events{}
}