**問題:#ifndef _gkosontimer_h_
#define _gkosontimer_h_
#include #include #include typedef void (*time_call_back)(void);
//節點的結構體
//因為我放棄了malloc只能引數自己攜帶記憶體 所以也對外提供節點的結構體
typedef struct _time
gtime_type;
//再次抽象 控制代碼結構體
typedef struct
time_ops_type;
//對外提供的控制代碼
extern time_ops_type gkosontimer;
//週期輪訓業務 輪訓鍊錶的函式
void gtimer_loop( void );
#endif
#include "gkosontimer.h"
#include "stdbool.h"
static uint8_t stimertaskid = 0; //表示每個節點的標號 此後可以對外釋放 方便開 和 關
static gtime_type *stimerhead = null; //鍊錶的頭結點
//遍歷鍊錶 週期loop執行
void gtimer_loop( void )
}priv = priv->next; }}
//關閉節點 《並沒有鍊錶移除 而是用標記位 優點:方便簡單 缺點:記憶體無法釋放》
uint8_t gtimer_stop_time(uint8_t handle)
priv = priv->next;
} return false;
}//開啟節點
uint8_t gtimer_start_time(uint8_t handle)
priv = priv->next;
} return false;
}//乙個節點新增到鍊錶 返回它的id
uint8_t gtimer_register_isr( gtime_type *timenode, uint32_t time_out ,uint8_t start, time_call_back call_back)
else
return (this->handle);
}time_ops_type gkosontimer =
;測試**
#include "gkosontimer.h"
uint8_t production_timer;
static void production_timeout_handler(void )
static void guitask(void *pvparameters)
}
1---每次開關都需要去遍歷效率低
2--維護的鍊錶來自每個static的自帶記憶體 主要是第二點導致前面必須去查詢==判斷
3--同樣是第二點導致**件必須對外提供節點的結構體
現在想優化一下
做乙個陣列池 這樣位址就是連續的 這樣的話每次不需要自帶記憶體 而且 開關我可以通過id直接關閉!第三點我完全封閉了!
後台loop就是程序調取 前面建立就是掛進來#ifndef _gkosontimer_h_
#define _gkosontimer_h_
#include #include #include typedef void (*time_call_back)(void);
//再次抽象 控制代碼結構體
typedef struct
time_ops_type;
//對外提供的控制代碼
extern time_ops_type gkosontimer;
//週期輪訓業務 輪訓鍊錶的函式
void gtimer_loop( void );
#endif
#include "gkosontimer.h"
#include "stdbool.h"
//節點的結構體
//因為我放棄了malloc只能引數自己攜帶記憶體 所以也對外提供節點的結構體
typedef struct _time
gtime_type;
static uint8_t stimertaskid = 0; //表示每個節點的標號 此後可以對外釋放 方便開 和 關
static gtime_type *stimerhead = null; //鍊錶的頭結點
#define max_gtimer_num 10
static gtime_type gtimer_memory_bank[max_gtimer_num]=;
gtime_type *gtimer_memory_alloc(uint8_t id)
//遍歷鍊錶 週期loop執行
void gtimer_loop( void )
}priv = priv->next; }}
//關閉節點
uint8_t gtimer_stop_time(uint8_t handle)
//開啟節點
uint8_t gtimer_start_time(uint8_t handle)
//乙個節點新增到鍊錶 返回它的id
uint8_t gtimer_register_isr(uint32_t time_out ,uint8_t start, time_call_back call_back)
else
return (this->handle);
}time_ops_type gkosontimer =
;static void guitask(void *pvparameters)
}
#ifndef _gkosontimer_h_
#define _gkosontimer_h_
#include #include #include typedef void (*time_call_back)(void);
//再次抽象 控制代碼結構體
typedef struct
time_ops_type;
//對外提供的控制代碼
extern time_ops_type gkosontimer;
//週期輪訓業務 輪訓鍊錶的函式
void gtimer_loop( void );
#endif
#include "gkosontimer.h"
#include "stdbool.h"
//節點的結構體
//因為我放棄了malloc只能引數自己攜帶記憶體 所以也對外提供節點的結構體
typedef struct _time
gtime_type;
static uint8_t stimertaskid = 0; //表示每個節點的標號 此後可以對外釋放 方便開 和 關
#define max_gtimer_num 10
static gtime_type gtimer_memory_bank[max_gtimer_num]=;
gtime_type *gtimer_memory_alloc(uint8_t id)
//遍歷鍊錶 週期loop執行
void gtimer_loop( void )}}
}//關閉節點
uint8_t gtimer_stop_time(uint8_t handle)
//開啟節點
uint8_t gtimer_start_time(uint8_t handle)
//乙個節點新增到鍊錶 返回它的id
uint8_t gtimer_register_isr(uint32_t time_out ,uint8_t start, time_call_back call_back)
else
#endif
return (this->handle);
}time_ops_type gkosontimer =
;static void guitask(void *pvparameters)
}
Mysql定時器定時刪除表資料
由於測試環境有張日誌表沒定時2分鐘程式就 資料,導致不到1乙個月時間,這張日誌表就占用了6.7g的空間,但是日誌重新整理較快,有些日誌就沒什麼作用,就寫了個定時器,定期刪除這張表的資料 首先先檢視mysql是否開啟定時任務開關 value為on則已開啟,off則關閉 如果是off,就先開啟 set ...
mysql定時器定時清理表資料
1.首先先檢視mysql是否開啟定時任務開關 2.value為on則已開啟,off則關閉 如果是off,就先開啟 set global event scheduler on 3.然後建立我們想要的定時器 delimiter drop event if exists deletelog create ...
mysql工具定時器 mysql的定時器
mysql定時器是系統給提供了event,而oracle裡面的定時器是系統給提供的job。廢話少說,下面建立表 create table mytable id int auto increment not null,name varchar 100 not null default introduc...