aboutsummaryrefslogtreecommitdiff
path: root/src/ats/ats_api_performance.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-03-19 10:04:49 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-03-19 10:04:49 +0000
commit5e53368a783e8dbf20a3f505a27f2e5549b7cf34 (patch)
tree739fe2eac01a5530830ec859a298ab30a2ee8d95 /src/ats/ats_api_performance.c
parent5df7f24fe0f8371c931b78a135c864af8e167c6a (diff)
downloadgnunet-5e53368a783e8dbf20a3f505a27f2e5549b7cf34.tar.gz
gnunet-5e53368a783e8dbf20a3f505a27f2e5549b7cf34.zip
performance monitor API + rename
Diffstat (limited to 'src/ats/ats_api_performance.c')
-rw-r--r--src/ats/ats_api_performance.c70
1 files changed, 66 insertions, 4 deletions
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c
index 25b492614..fc2d6647e 100644
--- a/src/ats/ats_api_performance.c
+++ b/src/ats/ats_api_performance.c
@@ -129,7 +129,7 @@ struct GNUNET_ATS_AddressListHandle
129 /** 129 /**
130 * Callback 130 * Callback
131 */ 131 */
132 GNUNET_ATS_PeerInformationCallback cb; 132 GNUNET_ATS_AddressInformationCallback cb;
133 133
134 /** 134 /**
135 * Callback closure 135 * Callback closure
@@ -171,7 +171,7 @@ struct GNUNET_ATS_PerformanceHandle
171 /** 171 /**
172 * Callback to invoke on performance changes. 172 * Callback to invoke on performance changes.
173 */ 173 */
174 GNUNET_ATS_PeerInformationCallback infocb; 174 GNUNET_ATS_AddressInformationCallback infocb;
175 175
176 /** 176 /**
177 * Closure for 'infocb'. 177 * Closure for 'infocb'.
@@ -214,6 +214,16 @@ struct GNUNET_ATS_PerformanceHandle
214 struct GNUNET_ATS_AddressListHandle *addresslist_tail; 214 struct GNUNET_ATS_AddressListHandle *addresslist_tail;
215 215
216 /** 216 /**
217 * Head of linked list of pending performance monitors.
218 */
219 struct GNUNET_ATS_PerformanceMonitorHandle *monitor_head;
220
221 /**
222 * Tail of linked list of pending performance monitors.
223 */
224 struct GNUNET_ATS_PerformanceMonitorHandle *monitor_tail;
225
226 /**
217 * Current request for transmission to ATS. 227 * Current request for transmission to ATS.
218 */ 228 */
219 struct GNUNET_CLIENT_TransmitHandle *th; 229 struct GNUNET_CLIENT_TransmitHandle *th;
@@ -629,7 +639,7 @@ reconnect (struct GNUNET_ATS_PerformanceHandle *ph)
629 */ 639 */
630struct GNUNET_ATS_PerformanceHandle * 640struct GNUNET_ATS_PerformanceHandle *
631GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg, 641GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
632 GNUNET_ATS_PeerInformationCallback infocb, 642 GNUNET_ATS_AddressInformationCallback infocb,
633 void *infocb_cls) 643 void *infocb_cls)
634{ 644{
635 struct GNUNET_ATS_PerformanceHandle *ph; 645 struct GNUNET_ATS_PerformanceHandle *ph;
@@ -643,6 +653,58 @@ GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
643 return ph; 653 return ph;
644} 654}
645 655
656struct GNUNET_ATS_PerformanceMonitorHandle
657{
658 struct GNUNET_ATS_PerformanceMonitorHandle *next;
659 struct GNUNET_ATS_PerformanceMonitorHandle *prev;
660
661 struct GNUNET_ATS_PerformanceHandle * ph;
662
663 GNUNET_ATS_PerformanceMonitorCb moncb;
664 void *moncb_cls;
665};
666
667/**
668 * Start monitoring performance information
669 *
670 * @param ph performance handle to use
671 * @param monitor_cb function to call on performance changes
672 * @param monitor_cb_cls closure for infocb
673 * @return a performance monitor handle
674 */
675struct GNUNET_ATS_PerformanceMonitorHandle *
676GNUNET_ATS_performance_monitor_start (struct GNUNET_ATS_PerformanceHandle * ph,
677 GNUNET_ATS_PerformanceMonitorCb monitor_cb,
678 void * monitor_cb_cls)
679{
680 GNUNET_assert (NULL != ph);
681
682 struct GNUNET_ATS_PerformanceMonitorHandle *phm =
683 GNUNET_malloc (sizeof (struct GNUNET_ATS_PerformanceMonitorHandle));
684
685 phm->ph = ph;
686 phm->moncb = monitor_cb;
687 phm->moncb_cls = monitor_cb_cls;
688 GNUNET_CONTAINER_DLL_insert (ph->monitor_head, ph->monitor_tail, phm);
689
690 return phm;
691}
692
693
694/**
695 * Stop monitoring performance information
696 *
697 * @param ph performance handle to use
698 * @param monitor_cb function to call on performance changes
699 * @param monitor_cb_cls closure for infocb
700 * @return a performance monitor handle
701 */
702void
703GNUNET_ATS_performance_monitor_stop (struct GNUNET_ATS_PerformanceMonitorHandle * phm)
704{
705 GNUNET_CONTAINER_DLL_remove (phm->ph->monitor_head, phm->ph->monitor_tail, phm);
706 GNUNET_free (phm);
707}
646 708
647/** 709/**
648 * Client is done using the ATS performance subsystem, release resources. 710 * Client is done using the ATS performance subsystem, release resources.
@@ -764,7 +826,7 @@ struct GNUNET_ATS_AddressListHandle*
764GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle, 826GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle,
765 const struct GNUNET_PeerIdentity *peer, 827 const struct GNUNET_PeerIdentity *peer,
766 int all, 828 int all,
767 GNUNET_ATS_PeerInformationCallback infocb, 829 GNUNET_ATS_AddressInformationCallback infocb,
768 void *infocb_cls) 830 void *infocb_cls)
769{ 831{
770 struct GNUNET_ATS_AddressListHandle *alh; 832 struct GNUNET_ATS_AddressListHandle *alh;