[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16493 - in gnunet/src: include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16493 - in gnunet/src: include util |
Date: |
Sun, 14 Aug 2011 13:12:46 +0200 |
Author: grothoff
Date: 2011-08-14 13:12:46 +0200 (Sun, 14 Aug 2011)
New Revision: 16493
Modified:
gnunet/src/include/gnunet_scheduler_lib.h
gnunet/src/util/disk.h
gnunet/src/util/scheduler.c
Log:
remove getter, make global static, add closure argument
Modified: gnunet/src/include/gnunet_scheduler_lib.h
===================================================================
--- gnunet/src/include/gnunet_scheduler_lib.h 2011-08-14 11:08:43 UTC (rev
16492)
+++ gnunet/src/include/gnunet_scheduler_lib.h 2011-08-14 11:12:46 UTC (rev
16493)
@@ -198,16 +198,18 @@
* 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
@@ -511,19 +513,13 @@
/**
* 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 */
{
Modified: gnunet/src/util/disk.h
===================================================================
--- gnunet/src/util/disk.h 2011-08-14 11:08:43 UTC (rev 16492)
+++ gnunet/src/util/disk.h 2011-08-14 11:12:46 UTC (rev 16493)
@@ -28,8 +28,6 @@
#include "gnunet_disk_lib.h"
-};
-
/**
* Retrieve OS file handle
*
Modified: gnunet/src/util/scheduler.c
===================================================================
--- gnunet/src/util/scheduler.c 2011-08-14 11:08:43 UTC (rev 16492)
+++ gnunet/src/util/scheduler.c 2011-08-14 11:12:46 UTC (rev 16493)
@@ -247,36 +247,29 @@
/**
* 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).
@@ -839,7 +832,12 @@
/* 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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16493 - in gnunet/src: include util,
gnunet <=