Skip to content
Snippets Groups Projects
Commit 35d81214 authored by Andreas Schärtl's avatar Andreas Schärtl
Browse files

[x] Comments

parent a9bb6868
No related tags found
No related merge requests found
......@@ -5,6 +5,9 @@ import (
)
// A Collector schedules the execution of various Jobs.
//
// It also keeps track of all previously submitted jobs. This is
// useful for keeping logs and the like.
type Collector struct {
// The Importer we forward the ULO/RDF bytes to.
Destination Importer
......@@ -22,19 +25,16 @@ func (c *Collector) Submit(j *Job) error {
return fmt.Errorf("Id=%v already submitted", id)
}
j.mu.Lock()
defer j.mu.Unlock()
go c.execute(j)
return nil
}
func (c *Collector) execute(j *Job) {
// Aquire lock as we need to set the status initially.
// (1) Aquire lock as we need to set the status initially.
j.mu.Lock()
// Set state to submitted. Later we'll want to do some kind
// (2) Set state to submitted. Later we'll want to do some kind
// of scheduling at which point a job can spend a lot of time
// in this state. But in the current version we don't do any
// clever scheduling and as such the job enters the Active
......@@ -42,19 +42,19 @@ func (c *Collector) execute(j *Job) {
j.state = Submitted
// Yep, we are starting already!
// (3) There is no scheduling. Start right away.
j.state = Active
// Now we give up the lock as we run the actual payload.
// (4) Now we give up the lock as we run the actual payload.
j.mu.Unlock()
// Run the actual payload.
// (5) Run the actual payload.
err := j.Collect(c)
// Set completion state.
// (6) Set completion state.
j.mu.Lock()
......@@ -67,7 +67,7 @@ func (c *Collector) execute(j *Job) {
j.wr.Release()
// We are done mutating the Job.
// (7) We are done mutating the Job.
j.mu.Unlock()
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment