X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fwin32%2Fsilcwin32schedule.c;h=383ececa98a37f09f54595899e8d820d7ed2711e;hb=d1e71f42379e8b5cd0748a7aeae8561b02cfe53d;hp=9321fecb823d33a1ac5f3378781229ff527163d4;hpb=8a338943d22f887cc96c432055b12be3ba14ebff;p=silc.git diff --git a/lib/silcutil/win32/silcwin32schedule.c b/lib/silcutil/win32/silcwin32schedule.c index 9321fecb..383ececa 100644 --- a/lib/silcutil/win32/silcwin32schedule.c +++ b/lib/silcutil/win32/silcwin32schedule.c @@ -4,12 +4,11 @@ Author: Pekka Riikonen - Copyright (C) 2001 Pekka Riikonen + Copyright (C) 2001 - 2005 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,7 +19,7 @@ /* $Id$ */ #include "silcincludes.h" -#includd "silcschedule_i.h" +#include "silcschedule_i.h" /* Our "select()" for WIN32. This mimics the behaviour of select() system call. It does not call the Winsock's select() though. Its functions @@ -50,10 +49,11 @@ */ -int silc_select(SilcScheduleFd fds, uint32 fds_count, struct timeval *timeout) +int silc_select(SilcScheduleFd fds, SilcUInt32 fds_count, struct timeval *timeout) { HANDLE handles[MAXIMUM_WAIT_OBJECTS]; - DWORD ready, curtime, timeo; + DWORD ready, curtime; + LONG timeo; int nhandles = 0, i; MSG msg; @@ -65,10 +65,13 @@ int silc_select(SilcScheduleFd fds, uint32 fds_count, struct timeval *timeout) continue; if (fds[i].events & SILC_TASK_READ) - handles[nhandles++] = (HANDLE)i; + handles[nhandles++] = (HANDLE)fds[i].fd; - if (fds[i].events & SILC_TASK_WRITE) + /* If writing then just set the bit and return */ + if (fds[i].events & SILC_TASK_WRITE) { + fds[i].revents = SILC_TASK_WRITE; return 1; + } fds[i].revents = 0; } @@ -96,6 +99,7 @@ int silc_select(SilcScheduleFd fds, uint32 fds_count, struct timeval *timeout) KillTimer(NULL, timer); if (timeo != INFINITE) { timeo -= GetTickCount() - curtime; + curtime = GetTickCount(); if (timeo < 0) timeo = 0; } @@ -134,14 +138,14 @@ int silc_select(SilcScheduleFd fds, uint32 fds_count, struct timeval *timeout) return and we will give the wait another try. */ if (timeo != INFINITE) { timeo -= GetTickCount() - curtime; + curtime = GetTickCount(); if (timeo < 0) timeo = 0; } /* Give the wait another try */ goto retry; - } else if (ready >= WAIT_OBJECT_0 && ready < WAIT_OBJECT_0 + nhandles && - readfds) { + } else if (ready >= WAIT_OBJECT_0 && ready < WAIT_OBJECT_0 + nhandles) { /* Some other event, like SOCKET or something. */ /* Go through all fds even though only one was set. This is to avoid @@ -186,14 +190,12 @@ SILC_TASK_CALLBACK(silc_schedule_wakeup_cb) #endif /* SILC_THREADS */ -/* Initializes the wakeup of the scheduler. In multi-threaded environment +/* Initializes the platform specific scheduler. This for example initializes + the wakeup mechanism of the scheduler. In multi-threaded environment the scheduler needs to be wakenup when tasks are added or removed from - the task queues. This will initialize the wakeup for the scheduler. - Any tasks that needs to be registered must be registered to the `queue'. - It is guaranteed that the scheduler will automatically free any - registered tasks in this queue. This is system specific routine. */ + the task queues. Returns context to the platform specific scheduler. */ -void *silc_schedule_wakeup_init(SilcSchedule schedule) +void *silc_schedule_internal_init(SilcSchedule schedule, void *app_context) { #ifdef SILC_THREADS SilcWin32Wakeup wakeup; @@ -223,9 +225,9 @@ void *silc_schedule_wakeup_init(SilcSchedule schedule) #endif } -/* Uninitializes the system specific wakeup. */ +/* Uninitializes the platform specific scheduler context. */ -void silc_schedule_wakeup_uninit(void *context) +void silc_schedule_internal_uninit(void *context) { #ifdef SILC_THREADS SilcWin32Wakeup wakeup = (SilcWin32Wakeup)context; @@ -240,7 +242,7 @@ void silc_schedule_wakeup_uninit(void *context) /* Wakes up the scheduler */ -void silc_schedule_wakeup_internal(void *context) +void silc_schedule_internal_wakeup(void *context) { #ifdef SILC_THREADS SilcWin32Wakeup wakeup = (SilcWin32Wakeup)context; @@ -251,3 +253,52 @@ void silc_schedule_wakeup_internal(void *context) ReleaseSemaphore(wakeup->wakeup_sema, 1, NULL); #endif } + +/* Register signal */ + +void silc_schedule_internal_signal_register(void *context, + SilcUInt32 signal, + SilcTaskCallback callback, + void *callback_context) +{ + +} + +/* Unregister signal */ + +void silc_schedule_internal_signal_unregister(void *context, + SilcUInt32 signal, + SilcTaskCallback callback, + void *callback_context) +{ + +} + +/* Mark signal to be called later. */ + +void silc_schedule_internal_signal_call(void *context, SilcUInt32 signal) +{ + +} + +/* Call all signals */ + +void silc_schedule_internal_signals_call(void *context, + SilcSchedule schedule) +{ + +} + +/* Block registered signals in scheduler. */ + +void silc_schedule_internal_signals_block(void *context) +{ + +} + +/* Unblock registered signals in schedule. */ + +void silc_schedule_internal_signals_unblock(void *context) +{ + +}