5 // This provides the interface that the score interfaces need to conform to.
15 interfaces = make(map[string]func(*TaskRequest)(ScoreInterface))
18 type ExecutionEnvironment struct {
19 Environment map[string]string
24 func NewExecutionEnvironment() (ee *ExecutionEnvironment) {
25 ee = new(ExecutionEnvironment)
26 ee.Environment = make(map[string]string)
31 type ScoreInterface interface {
32 // prepare gets called up front before the fork. It should do
33 // any/all lifting required.
35 // returns false if there are any problems.
38 // SetupEnvironment gets called prior to starting the child
39 // process. It should return an ExecutionEnvironment with the
40 // bits filled in the way it wants.
41 SetupProcess() *ExecutionEnvironment
43 // Cleanup is responsible for mopping up the mess, filing any
44 // results that need to be stored, etc. This will be called
45 // only from the main thread to ensure that results can be updated
50 func HasInterface(ifname string) bool {
51 _, exists := interfaces[ifname]
56 func RegisterInterface(ifname string, initfunc func(*TaskRequest)(ScoreInterface)) {
57 _, exists := interfaces[ifname]
59 o.Assert("Multiple attempts to register %s interface", ifname)
61 interfaces[ifname] = initfunc
64 func NewScoreInterface(task *TaskRequest) (iface ScoreInterface) {
65 score, exists := Scores[task.Score]
69 if !HasInterface(score.Interface) {
72 ifinit, _ := interfaces[score.Interface]