5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2002 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
24 #include "silcschedule_i.h"
26 /* Calls normal select() system call. */
28 int silc_select(SilcScheduleFd fds, SilcUInt32 fds_count, struct timeval *timeout)
31 int ret, i, max_fd = 0;
36 for (i = 0; i < fds_count; i++) {
40 if (fds[i].fd > max_fd)
43 if (fds[i].events & SILC_TASK_READ)
44 FD_SET(fds[i].fd, &in);
45 if (fds[i].events & SILC_TASK_WRITE)
46 FD_SET(fds[i].fd, &out);
51 /* ret = select(max_fd + 1, &in, &out, NULL, timeout); */
55 for (i = 0; i < fds_count; i++) {
59 if (FD_ISSET(fds[i].fd, &in))
60 fds[i].revents |= SILC_TASK_READ;
61 if (FD_ISSET(fds[i].fd, &out))
62 fds[i].revents |= SILC_TASK_WRITE;
70 /* XXX Do this like it's done in win32/ */
72 /* Internal wakeup context. */
77 SILC_TASK_CALLBACK(silc_schedule_wakeup_cb)
82 #endif /* SILC_THREADS */
84 /* Initializes the platform specific scheduler. This for example initializes
85 the wakeup mechanism of the scheduler. In multi-threaded environment
86 the scheduler needs to be wakenup when tasks are added or removed from
87 the task queues. Returns context to the platform specific scheduler. */
89 void *silc_schedule_internal_init(SilcSchedule schedule, void *context)
98 /* Uninitializes the platform specific scheduler context. */
100 void silc_schedule_internal_uninit(void *context)
107 /* Wakes up the scheduler */
109 void silc_schedule_internal_wakeup(void *context)
116 /* Register signal */
118 void silc_schedule_internal_signal_register(void *context,
120 SilcTaskCallback callback,
121 void *callback_context)
126 /* Unregister signal */
128 void silc_schedule_internal_signal_unregister(void *context,
130 SilcTaskCallback callback,
131 void *callback_context)
136 /* Mark signal to be called later. */
138 void silc_schedule_internal_signal_call(void *context, SilcUInt32 signal)
143 /* Call all signals */
145 void silc_schedule_internal_signals_call(void *context,
146 SilcSchedule schedule)
151 /* Block registered signals in scheduler. */
153 void silc_schedule_internal_signals_block(void *context)
158 /* Unblock registered signals in schedule. */
160 void silc_schedule_internal_signals_unblock(void *context)