* Signature of the select function used by the scheduler.
* GNUNET_NETWORK_socket_select matches it.
*
+ * @param cls closure
* @param rfds set of sockets to be checked for readability
* @param wfds set of sockets to be checked for writability
* @param efds set of sockets to be checked for exceptions
* @param timeout relative value when to return
* @return number of selected sockets, GNUNET_SYSERR on error
*/
-typedef int (*GNUNET_SCHEDULER_select) (struct GNUNET_NETWORK_FDSet *rfds,
- struct GNUNET_NETWORK_FDSet *wfds,
- struct GNUNET_NETWORK_FDSet *efds,
- struct GNUNET_TIME_Relative timeout);
+typedef int (*GNUNET_SCHEDULER_select) (void *cls,
+ struct GNUNET_NETWORK_FDSet *rfds,
+ struct GNUNET_NETWORK_FDSet *wfds,
+ struct GNUNET_NETWORK_FDSet *efds,
+ struct GNUNET_TIME_Relative timeout);
/**
* Initialize and run scheduler. This function will return when all
* tasks have completed. On systems with signals, receiving a SIGTERM
/**
* Sets the select function to use in the scheduler (scheduler_select).
*
- * @param new_select new select function to use
- * @return previously used select function
+ * @param new_select new select function to use (NULL to reset to default)
+ * @param new_select_cls closure for 'new_select'
*/
-GNUNET_SCHEDULER_select
-GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select);
+void
+GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select,
+ void *new_select_cls);
-/**
- * Gets the select function currently used in the scheduler.
- *
- * @return currently used select function
- */
-GNUNET_SCHEDULER_select
-GNUNET_SCHEDULER_get_select ();
#if 0 /* keep Emacsens' auto-indent happy */
{
/**
* Function to use as a select() in the scheduler.
- * Defaults to GNUNET_NETWORK_socket_select ()
+ * If NULL, we use GNUNET_NETWORK_socket_select ().
*/
-GNUNET_SCHEDULER_select scheduler_select = GNUNET_NETWORK_socket_select;
+static GNUNET_SCHEDULER_select scheduler_select;
+
+/**
+ * Closure for 'scheduler_select'.
+ */
+static void *scheduler_select_cls;
/**
* Sets the select function to use in the scheduler (scheduler_select).
*
* @param new_select new select function to use
- * @return previously used select function
+ * @return previously used select function, NULL for default
*/
-GNUNET_SCHEDULER_select
-GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select)
+void
+GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select,
+ void *new_select_cls)
{
- GNUNET_SCHEDULER_select old_select = scheduler_select;
scheduler_select = new_select;
- if (scheduler_select == NULL)
- scheduler_select = GNUNET_NETWORK_socket_select;
- return old_select;
+ scheduler_select_cls = new_select_cls;
}
-/**
- * Gets the select function currently used in the scheduler.
- *
- * @return currently used select function
- */
-GNUNET_SCHEDULER_select
-GNUNET_SCHEDULER_get_select ()
-{
- return scheduler_select;
-}
/**
* Check that the given priority is legal (and return it).
/* no blocking, more work already ready! */
timeout = GNUNET_TIME_UNIT_ZERO;
}
- ret = scheduler_select (rs, ws, NULL, timeout);
+ if (NULL == scheduler_select)
+ ret = GNUNET_NETWORK_socket_select (rs, ws, NULL, timeout);
+ else
+ ret = scheduler_select (scheduler_select_cls,
+ rs, ws, NULL,
+ timeout);
if (ret == GNUNET_SYSERR)
{
if (errno == EINTR)