ril event loop運作的示意圖
6,10的persist屬性為true
RIL event list是環狀的linked list
起始狀態的 list
加入一個event後
關於ril_event structure
struct ril_event {
struct ril_event *next;
struct ril_event *prev;
int fd;
int index;
bool persist;
struct timeval timeout;
ril_event_cb func;
void *param;
};
linking list的資料結構
fd: file descriptor
index: unknown
persist: 是否要從watch_table中移除
timeout: unknown
func: callback function
param: 傳入callback的data pointer
總共有timer list,pending list兩種list.(watch table是array的資料結構,不是linked list)
有以下幾種操作function
1.ril_event_set:
設置event,填入callback function,persist...等
2.ril_event_add:
將event加入watch table之中,並且將event的fd存入readFds全域變數之內與更新nfds(如果event的fd大於目前的value)
3.ril_event_del:
將event從watch table中刪除,並且將event中的fd從readFds中刪除
4.ril_timer_add:
將timer event加入timer list之中,下有程式碼說明
5.addToList:
將event加入list之中,下有程式碼說明
ril_timer_add
將timer event加入timer list之中, event的排序由timeout的時間從小到大
timeradd
將目前的系統時間加上timeout的間隔
addToList
將ev插入目前list指的後面那個位置
ril event loop
整個RILD的運作核心以下是event loop內function的說明
1.calNextTimeout
如果list是空的回傳-1,反之取出第一個event的timer減去目前的時間
如果event內的timeout時間小於目前取得的系統時間,time is expired ....
3.processReadReadies
檢查watch table內的event是否需要移到pending list等待被處裡
4.firePending
執行pending list中的event