This commit is contained in:
zogodo
2019-12-26 21:56:05 +08:00
parent 08b4dc8c35
commit 0a6f32c1ac
4 changed files with 12 additions and 11 deletions

View File

@@ -18,7 +18,7 @@ bool AddTask(pTimedTask task)
return true;
}
if (task->time <= task_top->time)
if (task->prs_time <= task_top->prs_time)
{
task->next = task_top;
task_top = task;
@@ -28,7 +28,7 @@ bool AddTask(pTimedTask task)
pTimedTask tmp = task_top;
while (tmp)
{
if ((task->time > tmp->time && task->time <= tmp->next->time)
if ((task->prs_time > tmp->prs_time && task->prs_time <= tmp->next->prs_time)
|| tmp->next == NULL)
{
task->next = tmp->next;
@@ -61,7 +61,7 @@ bool DelTask(int time)
return false;
}
if (time == task_top->time)
if (time == task_top->prs_time)
{
pTimedTask tmp = task_top;
task_top = task_top->next;
@@ -78,7 +78,7 @@ bool DelTask(int time)
pTimedTask tmp_tsk = task_top->next;
while (tmp_tsk)
{
if (time == tmp_tsk->time)
if (time == tmp_tsk->prs_time)
{
pre_tsk->next = tmp_tsk->next;
free(tmp_tsk);
@@ -101,7 +101,7 @@ char* GetTaskStr()
{
char buffer[26];
struct tm* tm_info;
tm_info = localtime(&tmp_tsk->time);
tm_info = localtime(&tmp_tsk->prs_time);
strftime(buffer, 26, "%Y-%m-%d %H:%M:%S", tm_info);
sprintf(tmp_str, "{time:'%s',socket_index:%d,on:%d},",

View File

@@ -1,10 +1,11 @@
#pragma once
#include <time.h>
struct TimedTask;
typedef struct TimedTask* pTimedTask;
struct TimedTask
{
int time; //被执行的格林尼治时间戳
time_t prs_time; //被执行的格林尼治时间戳
int socket_idx; //要控制的插孔
int on; //开或者关
pTimedTask next; //下一个任务(按之间排序)