Skip to content

Commit

Permalink
loading side of the threaded VM
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Jan 28, 2010
1 parent a544018 commit d5d55fc
Show file tree
Hide file tree
Showing 5 changed files with 288 additions and 62 deletions.
1 change: 1 addition & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Virtual Memory sub-TODO:
* Possibly decrRefCount() against swapped objects can be moved into I/O threads, as it's a slow operation against million elements list, and in general consumes CPU time that can be consumed by other threads (and cores).
* EXISTS should avoid loading the object if possible without too make the code too specialized.
* vm-min-age <seconds> option
* Make sure objects loaded from the VM are specially encoded when possible.

* Hashes (GET/SET/DEL/INCRBY/EXISTS/FIELDS/LEN/MSET/MGET). Special encoding for hashes with < N keys.

Expand Down
10 changes: 9 additions & 1 deletion ae.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ aeEventLoop *aeCreateEventLoop(void) {
eventLoop->timeEventNextId = 0;
eventLoop->stop = 0;
eventLoop->maxfd = -1;
eventLoop->beforesleep = NULL;
if (aeApiCreate(eventLoop) == -1) {
zfree(eventLoop);
return NULL;
Expand Down Expand Up @@ -373,10 +374,17 @@ int aeWait(int fd, int mask, long long milliseconds) {

void aeMain(aeEventLoop *eventLoop) {
eventLoop->stop = 0;
while (!eventLoop->stop)
while (!eventLoop->stop) {
if (eventLoop->beforesleep != NULL)
eventLoop->beforesleep(eventLoop);
aeProcessEvents(eventLoop, AE_ALL_EVENTS);
}
}

char *aeGetApiName(void) {
return aeApiName();
}

void aeSetBeforeSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *beforesleep) {
eventLoop->beforesleep = beforesleep;
}
3 changes: 3 additions & 0 deletions ae.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct aeEventLoop;
typedef void aeFileProc(struct aeEventLoop *eventLoop, int fd, void *clientData, int mask);
typedef int aeTimeProc(struct aeEventLoop *eventLoop, long long id, void *clientData);
typedef void aeEventFinalizerProc(struct aeEventLoop *eventLoop, void *clientData);
typedef void aeBeforeSleepProc(struct aeEventLoop *eventLoop);

/* File event structure */
typedef struct aeFileEvent {
Expand Down Expand Up @@ -93,6 +94,7 @@ typedef struct aeEventLoop {
aeTimeEvent *timeEventHead;
int stop;
void *apidata; /* This is used for polling API specific data */
aeBeforeSleepProc *beforesleep;
} aeEventLoop;

/* Prototypes */
Expand All @@ -110,5 +112,6 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags);
int aeWait(int fd, int mask, long long milliseconds);
void aeMain(aeEventLoop *eventLoop);
char *aeGetApiName(void);
void aeSetBeforeSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *beforesleep);

#endif
Loading

0 comments on commit d5d55fc

Please sign in to comment.