Mega patch
This is still a dirty prototype, so please excuse the mess. Please excuse the fact that this is a mega patch. Once things settle down this won't happen any more. Some of the changes squashed into here include: * Merge vertex loop with type loop (The file watcher seems to cache events anyways) * Improve pgraph library * Add indegree, outdegree, and topological sort with tests * Add reverse function for vertex list * Tons of additional cleanup! Amazingly, on my first successful compile, this seemed to run! A special thanks to Ira Cooper who helped me talk through some of the algorithmic decisions and for his help in finding better ones!
This commit is contained in:
36
event.go
36
event.go
@@ -17,20 +17,36 @@
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"code.google.com/p/go-uuid/uuid"
|
||||
//go:generate stringer -type=eventName -output=eventname_stringer.go
|
||||
type eventName int
|
||||
|
||||
const (
|
||||
eventExit eventName = iota
|
||||
eventStart
|
||||
eventPause
|
||||
eventContinue
|
||||
eventPoke
|
||||
eventChanged
|
||||
//eventPaused
|
||||
eventStarted
|
||||
)
|
||||
|
||||
type Event struct {
|
||||
uuid string
|
||||
Name string
|
||||
Type string
|
||||
Name eventName
|
||||
Resp chan bool // channel to send an ack response on, nil to skip
|
||||
//Wg *sync.WaitGroup // receiver barrier to Wait() for everyone else on
|
||||
Msg string // some words for fun
|
||||
}
|
||||
|
||||
func NewEvent(name, t string) *Event {
|
||||
return &Event{
|
||||
uuid: uuid.New(),
|
||||
Name: name,
|
||||
Type: t,
|
||||
// send a single acknowledgement on the channel if one was requested
|
||||
func (event *Event) ACK() {
|
||||
if event.Resp != nil { // if they've requested an ACK
|
||||
event.Resp <- true // send ACK
|
||||
}
|
||||
}
|
||||
|
||||
func (event *Event) NACK() {
|
||||
if event.Resp != nil { // if they've requested an ACK
|
||||
event.Resp <- false // send NACK
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user