Mike please suggest how to move this example to different file and link
with documentation.
I think that needs to be in ./example/timer/ directory and be build each
time. Otherwise very
soon documentation and code will not be synchronized.
Maxim.
On 12/17/2014 01:46 AM, Ola Liljedahl wrote:
--- a/platform/linux-generic/include/api/odp_timer.h
+++ b/platform/linux-generic/include/api/odp_timer.h
@@ -8,9 +8,211 @@
/**
* @file
*
- * ODP timer
+ * ODP timer service
*/
+/** Example #1 Retransmission timer (e.g. for reliable connections)
+ @code
+
+//Create timer pool for reliable connections
+#define SEC 1000000000ULL //1s expressed in nanoseconds
+odp_timer_pool_t tcp_tpid =
+ odp_timer_pool_create("TCP",
+ buffer_pool,
+ 1000000,//resolution 1ms
+ 0,//min tmo
+ 7200 * SEC,//max tmo length 2hours
+ 40000,//num_timers
+ true,//shared
+ ODP_CLOCK_CPU
+ );
+if (tcp_tpid == ODP_TIMER_POOL_INVALID)
+{
+ //Failed to create timer pool => fatal error
+}
+
+
+//Setting up a new connection
+//Allocate retransmission timeout (identical for supervision timeout)
+//The user pointer points back to the connection context
+conn->ret_tim = odp_timer_alloc(tcp_tpid, queue, conn);
+//Check if all resources were successfully allocated
+if (conn->ret_tim == ODP_TIMER_INVALID)
+{
+ //Failed to allocate all resources for connection => tear down
+ //Tear down connection
+ ...
+ return false;
+}
+//All necessary resources successfully allocated
+//Compute initi
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp