mirror of
https://github.com/Hizenberg469/Timer-Library.git
synced 2026-04-19 17:52:26 +03:00
Bug fix for get_time_remaining function
This commit is contained in:
20
include/WheelTimer.h
Normal file
20
include/WheelTimer.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef __WHEEL_TIMER_H
|
||||
#define __WHEEL_TIMER_H
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
typdedef struct _wheel_timer_t {
|
||||
|
||||
int current_clock_tic; /*Pointer to current slot, pointed by clock tic*/
|
||||
int clock_tic_interval; /*Time interval of each clock tick*/
|
||||
int wheel_size; /*No. of slots in wheel timer*/
|
||||
int current_cycle_no; /*No. of rotation completed by wheel timer clock tic*/
|
||||
pthread_t wheel_thread; /*Thread where the wheel timer clock run separately*/
|
||||
/*@@@@@@@@@@@@*/
|
||||
ll_t* slots[0]; /*Array of linked list, where each index in array represent a slot*/
|
||||
/*@@@@@@@@@@@@*/
|
||||
|
||||
} wheel_timer_t;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,13 +1,12 @@
|
||||
#timerlib.c src file...
|
||||
set(TIMER_LIB_SRC "timerlib.c")
|
||||
set(WHEEL_TIMER_LIB_SRC "WheelTimer.c")
|
||||
|
||||
#Library
|
||||
add_library(${TIMER_LIB} STATIC
|
||||
${TIMER_LIB_SRC})
|
||||
${TIMER_LIB_SRC}
|
||||
${WHEEL_TIMER_LIB_SRC})
|
||||
|
||||
#Including Header file dir...
|
||||
target_include_directories(${TIMER_LIB} PUBLIC
|
||||
${HEADER_DIR})
|
||||
|
||||
#Linking dependent library...
|
||||
|
||||
@@ -17,7 +16,15 @@ if( NOT (CMAKE_SYSTEM_NAME STREQUAL "Linux") )
|
||||
endif()
|
||||
|
||||
set(POSIX_TIMER_LIB rt)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
|
||||
target_link_libraries(${TIMER_LIB} PUBLIC
|
||||
${POSIX_TIMER_LIB})
|
||||
${POSIX_TIMER_LIB}
|
||||
Threads::Threads)
|
||||
|
||||
|
||||
#Including Header file dir...
|
||||
target_include_directories(${TIMER_LIB} PUBLIC
|
||||
${HEADER_DIR})
|
||||
0
src/WheelTimer.c
Normal file
0
src/WheelTimer.c
Normal file
@@ -48,12 +48,6 @@ timer_callback_wrapper(union sigval arg) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (timer->timer_state == TIMER_RESUMED) {
|
||||
if (timer->sec_exp_time != 0) {
|
||||
timer->timer_state = TIMER_RUNNING;
|
||||
}
|
||||
}
|
||||
|
||||
(timer->cb)(timer, timer->user_arg);
|
||||
|
||||
if (timer->exponential_backoff) {
|
||||
@@ -157,6 +151,7 @@ delete_timer(Timer_t* timer) {
|
||||
timer_set_state(timer, TIMER_DELETED);
|
||||
free(timer->posix_timer);
|
||||
free(timer);
|
||||
timer = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user