MCPcopy Create free account
hub / github.com/F-Stack/f-stack / aeCreateEventLoop

Function aeCreateEventLoop

app/redis-6.2.6/src/ae.c:71–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69
70
71aeEventLoop *aeCreateEventLoop(int setsize) {
72 aeEventLoop *eventLoop;
73 int i;
74
75 monotonicInit(); /* just in case the calling app didn't initialize */
76
77 if ((eventLoop = zmalloc(sizeof(*eventLoop))) == NULL) goto err;
78 eventLoop->events = zmalloc(sizeof(aeFileEvent)*setsize);
79 eventLoop->fired = zmalloc(sizeof(aeFiredEvent)*setsize);
80 if (eventLoop->events == NULL || eventLoop->fired == NULL) goto err;
81 eventLoop->setsize = setsize;
82 eventLoop->timeEventHead = NULL;
83 eventLoop->timeEventNextId = 0;
84 eventLoop->stop = 0;
85 eventLoop->maxfd = -1;
86 eventLoop->beforesleep = NULL;
87 eventLoop->aftersleep = NULL;
88 eventLoop->flags = 0;
89 if (aeApiCreate(eventLoop) == -1) goto err;
90 /* Events with mask == AE_NONE are not set. So let's initialize the
91 * vector with it. */
92 for (i = 0; i < setsize; i++)
93 eventLoop->events[i].mask = AE_NONE;
94 return eventLoop;
95
96err:
97 if (eventLoop) {
98 zfree(eventLoop->events);
99 zfree(eventLoop->fired);
100 zfree(eventLoop);
101 }
102 return NULL;
103}
104
105/* Return the current set size. */
106int aeGetSetSize(aeEventLoop *eventLoop) {

Callers 4

initServerFunction · 0.85
createBenchmarkThreadFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 4

monotonicInitFunction · 0.85
zmallocFunction · 0.85
aeApiCreateFunction · 0.70
zfreeFunction · 0.70

Tested by

no test coverage detected