pool.go
func (pool *Pool) WaitForJob() *Job {
	result_pipe := make(chan *Job)
	var job *Job
	var ok bool
	for {
		pool.result_wanted_pipe <- result_pipe
		job, ok = <-result_pipe
		if !ok {
			// no more results available
			return nil
		}
		if job == (*Job)(nil) {
			// no result available right now but there are jobs running
			time.Sleep(pool.interval * time.Millisecond)
		} else {
			break
		}
	}
	return job
}
func (pool *Pool) WaitForJob() *Job {
	result_pipe := make(chan *Job)
	var job *Job
	var ok bool
	for {
		pool.result_wanted_pipe <- result_pipe
		job, ok = <-result_pipe
		if !ok {
			// no more results available
			return nil
		}
		if job == (*Job)(nil) {
			// no result available right now but there are jobs running
			time.Sleep(pool.interval * time.Millisecond)
		} else {
			break
		}
	}
	return job
}
// WaitForJob blocks until a completed job is available and returns it.
// If there are no jobs running, it returns nil.