添加事件监听注释
This commit is contained in:
parent
29943ec366
commit
ce6b9b103b
4
src/ae.c
4
src/ae.c
@ -314,7 +314,7 @@ static int processTimeEvents(aeEventLoop *eventLoop) {
|
|||||||
long now_sec, now_ms;
|
long now_sec, now_ms;
|
||||||
long long id;
|
long long id;
|
||||||
|
|
||||||
/* Remove events scheduled for deletion. */
|
/* 删除已经指定要删除的事件 */
|
||||||
if (te->id == AE_DELETED_EVENT_ID) {
|
if (te->id == AE_DELETED_EVENT_ID) {
|
||||||
aeTimeEvent *next = te->next;
|
aeTimeEvent *next = te->next;
|
||||||
/* If a reference exists for this timer event,
|
/* If a reference exists for this timer event,
|
||||||
@ -354,9 +354,11 @@ static int processTimeEvents(aeEventLoop *eventLoop) {
|
|||||||
|
|
||||||
id = te->id;
|
id = te->id;
|
||||||
te->refcount++;
|
te->refcount++;
|
||||||
|
// 处理时间事件
|
||||||
retval = te->timeProc(eventLoop, id, te->clientData);
|
retval = te->timeProc(eventLoop, id, te->clientData);
|
||||||
te->refcount--;
|
te->refcount--;
|
||||||
processed++;
|
processed++;
|
||||||
|
// 重新设置时间事件到期时间
|
||||||
if (retval != AE_NOMORE) {
|
if (retval != AE_NOMORE) {
|
||||||
aeAddMillisecondsToNow(retval,&te->when_sec,&te->when_ms);
|
aeAddMillisecondsToNow(retval,&te->when_sec,&te->when_ms);
|
||||||
} else {
|
} else {
|
||||||
|
20
src/ae.h
20
src/ae.h
@ -79,13 +79,13 @@ typedef struct aeFileEvent {
|
|||||||
/* Time event structure */
|
/* Time event structure */
|
||||||
typedef struct aeTimeEvent {
|
typedef struct aeTimeEvent {
|
||||||
long long id; /* time event identifier. */
|
long long id; /* time event identifier. */
|
||||||
long when_sec; /* seconds */
|
long when_sec; /* 事件触发的秒数 */
|
||||||
long when_ms; /* milliseconds */
|
long when_ms; /* 事件触发的毫秒数 */
|
||||||
aeTimeProc *timeProc;
|
aeTimeProc *timeProc;/* 指向时间事件的处理函数 */
|
||||||
aeEventFinalizerProc *finalizerProc;
|
aeEventFinalizerProc *finalizerProc;/* 事件删除的时候会调用的函数 */
|
||||||
void *clientData;
|
void *clientData;/* 指向对应的客户端对象 */
|
||||||
struct aeTimeEvent *prev;
|
struct aeTimeEvent *prev;/* 指向上一个时间事件节点 */
|
||||||
struct aeTimeEvent *next;
|
struct aeTimeEvent *next;/* 指向时下一个时间事件节点 */
|
||||||
int refcount; /* refcount to prevent timer events from being
|
int refcount; /* refcount to prevent timer events from being
|
||||||
* freed in recursive time event calls. */
|
* freed in recursive time event calls. */
|
||||||
} aeTimeEvent;
|
} aeTimeEvent;
|
||||||
@ -102,10 +102,10 @@ typedef struct aeEventLoop {
|
|||||||
int setsize; /* max number of file descriptors tracked */
|
int setsize; /* max number of file descriptors tracked */
|
||||||
long long timeEventNextId;
|
long long timeEventNextId;
|
||||||
time_t lastTime; /* Used to detect system clock skew */
|
time_t lastTime; /* Used to detect system clock skew */
|
||||||
aeFileEvent *events; /* Registered events */
|
aeFileEvent *events; /* 注册过的事件 */
|
||||||
aeFiredEvent *fired; /* Fired events */
|
aeFiredEvent *fired; /* 已经触发过的事件*/
|
||||||
aeTimeEvent *timeEventHead;
|
aeTimeEvent *timeEventHead;
|
||||||
int stop;
|
int stop; /* 事件循环是否结束 */
|
||||||
void *apidata; /* This is used for polling API specific data */
|
void *apidata; /* This is used for polling API specific data */
|
||||||
aeBeforeSleepProc *beforesleep;
|
aeBeforeSleepProc *beforesleep;
|
||||||
aeBeforeSleepProc *aftersleep;
|
aeBeforeSleepProc *aftersleep;
|
||||||
|
@ -1961,7 +1961,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We need to do a few operations on clients asynchronously. */
|
/* 清除无用客户端连接 */
|
||||||
clientsCron();
|
clientsCron();
|
||||||
|
|
||||||
/* Handle background operations on Redis databases. */
|
/* Handle background operations on Redis databases. */
|
||||||
|
Loading…
Reference in New Issue
Block a user