summaryrefslogtreecommitdiff
path: root/src/ivyloop.c
diff options
context:
space:
mode:
authorfcolin2006-06-28 09:05:30 +0000
committerfcolin2006-06-28 09:05:30 +0000
commit53f1cd3c774bc45c09a1fe90f9d27a5c5feee785 (patch)
tree6160bedc1c177cacb6ddb328b9524c0edabe10e5 /src/ivyloop.c
parent19735bb3c818f78d5ce53d1482b0bd62f63d76e8 (diff)
downloadivy-c-53f1cd3c774bc45c09a1fe90f9d27a5c5feee785.zip
ivy-c-53f1cd3c774bc45c09a1fe90f9d27a5c5feee785.tar.gz
ivy-c-53f1cd3c774bc45c09a1fe90f9d27a5c5feee785.tar.bz2
ivy-c-53f1cd3c774bc45c09a1fe90f9d27a5c5feee785.tar.xz
Modification API Hook sur IvyMainLoop
Diffstat (limited to 'src/ivyloop.c')
-rw-r--r--src/ivyloop.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/ivyloop.c b/src/ivyloop.c
index a407fae..897267b 100644
--- a/src/ivyloop.c
+++ b/src/ivyloop.c
@@ -56,6 +56,13 @@ static int channel_initialized = 0;
static fd_set open_fds;
static int MainLoop = 1;
+/* Hook callback & data */
+static IvyHookPtr BeforeSelect = NULL;
+static IvyHookPtr AfterSelect = NULL;
+
+static void *BeforeSelectData = NULL;
+static void *AfterSelectData = NULL;
+
#ifdef WIN32
WSADATA WsaData;
#endif
@@ -158,7 +165,7 @@ void IvyChannelStop (void)
MainLoop = 0;
}
-void IvyMainLoop(void(*BeforeSelect)(void),void(*AfterSelect)(void))
+void IvyMainLoop()
{
fd_set rdset;
@@ -166,20 +173,24 @@ void IvyMainLoop(void(*BeforeSelect)(void),void(*AfterSelect)(void))
int ready;
while (MainLoop) {
+
ChannelDefferedDelete();
- if (BeforeSelect) (*BeforeSelect)();
+
+ if (BeforeSelect)
+ (*BeforeSelect)(BeforeSelectData);
rdset = open_fds;
exset = open_fds;
ready = select(64, &rdset, 0, &exset, TimerGetSmallestTimeout());
- /* for compatibility with older version we test also the first parameter */
- if (BeforeSelect && AfterSelect) (*AfterSelect)();
+
+ if (AfterSelect)
+ (*AfterSelect)(AfterSelectData);
if (ready < 0 && (errno != EINTR)) {
fprintf (stderr, "select error %d\n",errno);
perror("select");
return;
}
- TimerScan();
+ TimerScan(); /* should be spliited in two part ( next timeout & callbacks */
if (ready > 0) {
IvyChannelHandleExcpt(&exset);
IvyChannelHandleRead(&rdset);
@@ -212,3 +223,14 @@ void IvyIdle()
}
+
+void IvySetBeforeSelectHook(IvyHookPtr before, void *data )
+{
+ BeforeSelect = before;
+ BeforeSelectData = data;
+}
+void IvySetAfterSelectHook(IvyHookPtr after, void *data )
+{
+ AfterSelect = after;
+ AfterSelectData = data;
+}