瀏覽代碼

using time.After instead of a separate goroutine

tags/0.1.1
mikespook 12 年之前
父節點
當前提交
624c61519f
共有 1 個檔案被更改,包括 1 行新增8 行删除
  1. +1
    -8
      client/client.go

+ 1
- 8
client/client.go 查看文件

@@ -235,17 +235,10 @@ func (client *Client) Do(funcname string, data []byte, flag byte) (handle string
rel = append(rel, data...) // len(data)
client.writeJob(newJob(common.REQ, datatype, rel))
// Waiting for JOB_CREATED
timeout := make(chan bool)
defer close(timeout)
go func() {
defer common.DisablePanic()
time.Sleep(client.TimeOut)
timeout <- true
}()
select {
case job := <-client.jobCreated:
return string(job.Data), nil
case <-timeout:
case <-time.After(client.TimeOut):
return "", common.ErrJobTimeOut
}
return


Loading…
取消
儲存