mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
添加 删除 定时任务 接口
This commit is contained in:
@@ -40,7 +40,7 @@ bool AddTask(pTimedTask task)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DelTask()
|
||||
bool DelFirstTask()
|
||||
{
|
||||
if (task_top)
|
||||
{
|
||||
@@ -53,6 +53,39 @@ bool DelTask()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DelTask(int time)
|
||||
{
|
||||
if (task_top == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (time == task_top->time)
|
||||
{
|
||||
pTimedTask tmp = task_top;
|
||||
task_top = task_top->next;
|
||||
free(task_top);
|
||||
return true;
|
||||
}
|
||||
else if (task_top->next == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
pTimedTask pre_tsk = task_top;
|
||||
pTimedTask tmp_tsk = task_top->next;
|
||||
while (tmp_tsk)
|
||||
{
|
||||
if (time == tmp_tsk->time)
|
||||
{
|
||||
pre_tsk->next = tmp_tsk->next;
|
||||
free(tmp_tsk);
|
||||
}
|
||||
tmp_tsk = tmp_tsk->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
char* GetTaskStr()
|
||||
{
|
||||
char* str = (char*)malloc(sizeof(char)*task_count * 40);
|
||||
|
||||
Reference in New Issue
Block a user