| 493 | } |
| 494 | |
| 495 | extern "C" long long aeCreateTimeEvent(aeEventLoop *eventLoop, long long milliseconds, |
| 496 | aeTimeProc *proc, void *clientData, |
| 497 | aeEventFinalizerProc *finalizerProc) |
| 498 | { |
| 499 | serverAssert(g_eventLoopThisThread == NULL || g_eventLoopThisThread == eventLoop); |
| 500 | long long id = eventLoop->timeEventNextId++; |
| 501 | aeTimeEvent *te; |
| 502 | |
| 503 | te = (aeTimeEvent*)zmalloc(sizeof(*te), MALLOC_LOCAL); |
| 504 | if (te == NULL) return AE_ERR; |
| 505 | te->id = id; |
| 506 | te->when = getMonotonicUs() + milliseconds * 1000; |
| 507 | te->timeProc = proc; |
| 508 | te->finalizerProc = finalizerProc; |
| 509 | te->clientData = clientData; |
| 510 | te->prev = NULL; |
| 511 | te->next = eventLoop->timeEventHead; |
| 512 | te->refcount = 0; |
| 513 | if (te->next) |
| 514 | te->next->prev = te; |
| 515 | eventLoop->timeEventHead = te; |
| 516 | return id; |
| 517 | } |
| 518 | |
| 519 | extern "C" int aeDeleteTimeEvent(aeEventLoop *eventLoop, long long id) |
| 520 | { |
no test coverage detected