On 17 December 2014 at 23:53, Maxim Uvarov <[email protected]> wrote:
> Mike please suggest how to move this example to different file and link with
> documentation.
What example are you thinking of? The code snippets in odp_timer.h?
Those are not real working examples, that will take a lot more boiler
plate code (e.g. creating buffer pools and queues etc) that is not
relevant here.

> 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.
Well those code snippets are in the same header file which defines the
API in question.

I wouldn't mind morphing the current example/timer/odp_timer_test.c
(should be renamed to odp_timer_example.c) into a working example that
exemplifies some of the cases in odp_timer.h. If this turns out well,
I can consider removing the code snippets from odp_timer.h.

>
> 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

_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to