package utl /** A job should be callable so there may be 2 types of jobs at least */ type IJob interface { Exec(interface{}) error } type IJobFn func(interface{}) error type TJobChan chan *Job type TJobPool chan TJobChan func (fn IJobFn) Exec(inf interface{}) error { return fn(inf) } type Job struct { param interface{} job IJob } func NewJob(job IJob, param interface{}) *Job { return &Job{ param: param, job: job, } } func (self *Job) Do() error { return self.job.Exec(self.param) }