gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r26485 - in gnunet/src: ats include


From: gnunet
Subject: [GNUnet-SVN] r26485 - in gnunet/src: ats include
Date: Tue, 19 Mar 2013 11:04:49 +0100

Author: wachs
Date: 2013-03-19 11:04:49 +0100 (Tue, 19 Mar 2013)
New Revision: 26485

Modified:
   gnunet/src/ats/ats_api_performance.c
   gnunet/src/include/gnunet_ats_service.h
Log:
performance monitor API + rename


Modified: gnunet/src/ats/ats_api_performance.c
===================================================================
--- gnunet/src/ats/ats_api_performance.c        2013-03-19 09:58:55 UTC (rev 
26484)
+++ gnunet/src/ats/ats_api_performance.c        2013-03-19 10:04:49 UTC (rev 
26485)
@@ -129,7 +129,7 @@
   /**
    * Callback
    */
-  GNUNET_ATS_PeerInformationCallback cb;
+  GNUNET_ATS_AddressInformationCallback cb;
 
   /**
    * Callback closure
@@ -171,7 +171,7 @@
   /**
    * Callback to invoke on performance changes.
    */
-  GNUNET_ATS_PeerInformationCallback infocb;
+  GNUNET_ATS_AddressInformationCallback infocb;
 
   /**
    * Closure for 'infocb'.
@@ -214,6 +214,16 @@
   struct GNUNET_ATS_AddressListHandle *addresslist_tail;
 
   /**
+   * Head of linked list of pending performance monitors.
+   */
+  struct GNUNET_ATS_PerformanceMonitorHandle *monitor_head;
+
+  /**
+   * Tail of linked list of pending performance monitors.
+   */
+  struct GNUNET_ATS_PerformanceMonitorHandle *monitor_tail;
+
+  /**
    * Current request for transmission to ATS.
    */
   struct GNUNET_CLIENT_TransmitHandle *th;
@@ -629,7 +639,7 @@
  */
 struct GNUNET_ATS_PerformanceHandle *
 GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                             GNUNET_ATS_PeerInformationCallback infocb,
+                             GNUNET_ATS_AddressInformationCallback infocb,
                              void *infocb_cls)
 {
   struct GNUNET_ATS_PerformanceHandle *ph;
@@ -643,8 +653,60 @@
   return ph;
 }
 
+struct GNUNET_ATS_PerformanceMonitorHandle
+{
+       struct GNUNET_ATS_PerformanceMonitorHandle *next;
+       struct GNUNET_ATS_PerformanceMonitorHandle *prev;
 
+       struct GNUNET_ATS_PerformanceHandle * ph;
+
+       GNUNET_ATS_PerformanceMonitorCb moncb;
+       void *moncb_cls;
+};
+
 /**
+ * Start monitoring performance information
+ *
+ * @param ph performance handle to use
+ * @param monitor_cb function to call on performance changes
+ * @param monitor_cb_cls closure for infocb
+ * @return a performance monitor handle
+ */
+struct GNUNET_ATS_PerformanceMonitorHandle *
+GNUNET_ATS_performance_monitor_start (struct GNUNET_ATS_PerformanceHandle * ph,
+                                                                               
                                                                        
GNUNET_ATS_PerformanceMonitorCb monitor_cb,
+                                                                               
                                                                        void * 
monitor_cb_cls)
+{
+       GNUNET_assert (NULL != ph);
+
+       struct GNUNET_ATS_PerformanceMonitorHandle *phm =
+                       GNUNET_malloc (sizeof (struct 
GNUNET_ATS_PerformanceMonitorHandle));
+
+       phm->ph = ph;
+       phm->moncb = monitor_cb;
+       phm->moncb_cls = monitor_cb_cls;
+       GNUNET_CONTAINER_DLL_insert (ph->monitor_head, ph->monitor_tail, phm);
+
+       return phm;
+}
+
+
+/**
+ * Stop monitoring performance information
+ *
+ * @param ph performance handle to use
+ * @param monitor_cb function to call on performance changes
+ * @param monitor_cb_cls closure for infocb
+ * @return a performance monitor handle
+ */
+void
+GNUNET_ATS_performance_monitor_stop (struct 
GNUNET_ATS_PerformanceMonitorHandle * phm)
+{
+       GNUNET_CONTAINER_DLL_remove (phm->ph->monitor_head, 
phm->ph->monitor_tail, phm);
+       GNUNET_free (phm);
+}
+
+/**
  * Client is done using the ATS performance subsystem, release resources.
  *
  * @param ph handle
@@ -764,7 +826,7 @@
 GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle 
*handle,
                                        const struct GNUNET_PeerIdentity *peer,
                                        int all,
-                                       GNUNET_ATS_PeerInformationCallback 
infocb,
+                                       GNUNET_ATS_AddressInformationCallback 
infocb,
                                        void *infocb_cls)
 {
   struct GNUNET_ATS_AddressListHandle *alh;

Modified: gnunet/src/include/gnunet_ats_service.h
===================================================================
--- gnunet/src/include/gnunet_ats_service.h     2013-03-19 09:58:55 UTC (rev 
26484)
+++ gnunet/src/include/gnunet_ats_service.h     2013-03-19 10:04:49 UTC (rev 
26485)
@@ -697,9 +697,23 @@
  */
 struct GNUNET_ATS_PerformanceHandle;
 
+/**
+ * Signature of a function that is called with QoS information about an peer.
+ *
+ * @param cls closure
+ * @param peer the peer
+ * @param ats data for the peer
+ * @param ats_count number of performance records in 'ats'
+ */
+typedef void
+(*GNUNET_ATS_PerformanceMonitorCb) (void *cls,
+                                                                               
                                                                struct 
GNUNET_PeerIdentity *peer,
+                                                                               
                                                                struct 
GNUNET_ATS_Information *ats,
+                                                                               
                                                                uint32_t 
ats_count);
 
+
 /**
- * Signature of a function that is called with QoS information about a peer.
+ * Signature of a function that is called with QoS information about an 
address.
  *
  * @param cls closure
  * @param address the address
@@ -708,7 +722,7 @@
  * @param ats performance data for the address (as far as known)
  * @param ats_count number of performance records in 'ats'
  */
-typedef void (*GNUNET_ATS_PeerInformationCallback) (void *cls,
+typedef void (*GNUNET_ATS_AddressInformationCallback) (void *cls,
                                                     const struct
                                                     GNUNET_HELLO_Address *
                                                     address,
@@ -738,11 +752,38 @@
  */
 struct GNUNET_ATS_PerformanceHandle *
 GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                             GNUNET_ATS_PeerInformationCallback infocb,
+                             GNUNET_ATS_AddressInformationCallback infocb,
                              void *infocb_cls);
 
 
 /**
+ * Start monitoring performance information
+ *
+ * @param ph performance handle to use
+ * @param monitor_cb function to call on performance changes
+ * @param monitor_cb_cls closure for infocb
+ * @return a performance monitor handle
+ */
+struct GNUNET_ATS_PerformanceMonitorHandle *
+GNUNET_ATS_performance_monitor_start (struct GNUNET_ATS_PerformanceHandle * ph,
+                                                                               
                                                                        
GNUNET_ATS_PerformanceMonitorCb monitor_cb,
+                                                                               
                                                                        void * 
monitor_cb_cls);
+
+
+/**
+ * Stop monitoring performance information
+ *
+ * @param ph performance handle to use
+ * @param monitor_cb function to call on performance changes
+ * @param monitor_cb_cls closure for infocb
+ * @return a performance monitor handle
+ */
+void
+GNUNET_ATS_performance_monitor_stop (struct 
GNUNET_ATS_PerformanceMonitorHandle * phm);
+
+
+
+/**
  * Get information about addresses known to the ATS subsystem.
  *
  * @param handle the performance handle to use
@@ -758,7 +799,7 @@
 GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle 
*handle,
                                        const struct GNUNET_PeerIdentity *peer,
                                        int all,
-                                       GNUNET_ATS_PeerInformationCallback 
infocb,
+                                       GNUNET_ATS_AddressInformationCallback 
infocb,
                                        void *infocb_cls);
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]