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

Re: [libvirt] [PATCH v2 1/2] timer impl



At 2010-12-15 14:32, Hu Tao Write:
> On Wed, Dec 15, 2010 at 10:34:25AM +0800, Wen Congyang wrote:
>> * src/util/timer.c src/util/timer.h src/util/timer_linux.c src/util/timer_win32.c:
>>   timer implementation
>> * src/Makefile.am: build timer
>> * src/libvirt_private.syms: Export public functions
>> * src/libvirt.c: Initialize timer
>> * configure.ac: check the functions in librt used by timer
>>
>> Signed-off-by: Wen Congyang <wency cn fujitsu com>
>>
>> ---

<snip>
> 
> However, I'd suggest providing APIs just wrapping around OS specific
> timer implementations. For linux they look like these:
> 
> struct virTimer {
>     timer_t timer;
> };
> 
> virTimerPtr virNewTimer(virTimerCB cb, void *opaque)
> {
>     virTimerPtr timer;
> 
>     ...
> 
>     timer_event.sigev_notify = SIGEV_THREAD;
>     timer_event.sigev_notify_function = cb;
>     timer_event.sigev_notify_attributes = &timer_thread_attr;
>     timer_event.sigev_value.sival_ptr = opaque;
> 
>     ret = timer_create(CLOCK_MONOTONIC, &timer_event, &timer->timer);
> 
>     ...
> }
> 
> void virModTimer(virTimerPtr timer, uint64_t expire_time)
> {
>     ...
> 
>     timer_settime(timer->timer, ...);
> }
> 

Good idea. Thanks.


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