diff --git a/execute_plan.go b/execute_plan.go index 2acfd09..e3242ab 100644 --- a/execute_plan.go +++ b/execute_plan.go @@ -1,9 +1,5 @@ package imitate -import ( - "github.com/474420502/requests" -) - // type ExecuteRecord struct { // IsSuccess bool // FailCount int @@ -24,34 +20,32 @@ type IExecute interface { } // ExecutePlan 执行时间的计划表 -type ExecutePlan struct { - ExecuteQueue []IExecute -} +type ExecutePlan CircularLinked -// PlanResult 执行计划表的结果 -type PlanResult struct { - Exec IExecute - Resp *requests.Response -} +// // PlanResult 执行计划表的结果 +// type PlanResult struct { +// Exec IExecute +// Resp *requests.Response +// } -// NewExecutePlan create a plan -func NewExecutePlan() *ExecutePlan { - plan := &ExecutePlan{} +// // NewExecutePlan create a plan +// func NewExecutePlan() *ExecutePlan { +// plan := &ExecutePlan{} +// plan.ExecuteQueue = NewCircularLinked() +// return plan +// } - return plan -} +// // AppendIExecute 添加执行计划任务 +// func (ep *ExecutePlan) AppendIExecute(e IExecute) { +// ep.ExecuteQueue.Append(e) +// } -// AppendIExecute 添加执行计划任务 -func (ep *ExecutePlan) AppendIExecute(e IExecute) { - ep.ExecuteQueue = append(ep.ExecuteQueue, e) -} +// // ClearIExecute 清除执行计划任务 +// func (ep *ExecutePlan) ClearIExecute() { +// ep.ExecuteQueue = NewCircularLinked() +// } -// ClearIExecute 清除执行计划任务 -func (ep *ExecutePlan) ClearIExecute() { - ep.ExecuteQueue = []IExecute{} -} - -// CountIExecute 清除执行计划任务 -func (ep *ExecutePlan) CountIExecute() int { - return len(ep.ExecuteQueue) -} +// // CountIExecute 清除执行计划任务 +// func (ep *ExecutePlan) CountIExecute() uint64 { +// return ep.ExecuteQueue.Size() +// } diff --git a/execute_test.go b/execute_test.go index f5de1d1..33457e1 100644 --- a/execute_test.go +++ b/execute_test.go @@ -12,19 +12,23 @@ import ( type Person struct { Tasks []Task + Conf *Config } type Task struct { Curl *curl2info.CURL - Conf *Config Plan *ExecutePlan } -func NewTask(conf string, curlinfo string) *Task { - task := &Task{} +func NewPerson(conf string, curlinfo string) *Person { + return nil +} - task.Conf = NewConfig(conf) +func NewTask(curlinfo string, Plan *ExecutePlan) *Task { + task := &Task{} + // task.Conf = NewConfig(conf) task.Curl = curl2info.NewCURL(curlinfo) + task.Plan = Plan return task } diff --git a/structure.go b/structure.go index 949e02f..415378a 100644 --- a/structure.go +++ b/structure.go @@ -191,6 +191,15 @@ func (list *CircularLinked) Size() uint64 { return list.size } +// Clone 复制一个完整的链表, 只是value引用, 如果是指针他们(链表)之间, 操作value会可能产生影响 +func (list *CircularLinked) Clone() *CircularLinked { + cl := NewCircularLinked() + for i := uint64(0); i < list.size; i++ { + cl.Append(list.cursor.value) + } + return cl +} + func (list *CircularLinked) errorNotInList(node *Node) { log.Println("the node value ", spew.Sprint(node), " is not in list") }