Permalink
Browse files

loading side of the threaded VM

  • Loading branch information...
antirez committed Jan 28, 2010
1 parent a544018 commit d5d55fc3195f1c0749440c3b698c00f288513a8d
Showing with 288 additions and 62 deletions.
  1. +1 −0 TODO
  2. +9 −1 ae.c
  3. +3 −0 ae.h
  4. +270 −61 redis.c
  5. +5 −0 staticsymbols.h
View
1 TODO
@@ -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.
View
10 ae.c
@@ -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;
@@ -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;
+}
View
3 ae.h
@@ -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 {
@@ -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 */
@@ -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
Oops, something went wrong.

0 comments on commit d5d55fc

Please sign in to comment.