/*
 * Created by hongbo.he@lnxall.com
 *
 * 2025/09/01
 */
#ifndef LNXUTILS_TIMER_H
#define LNXUTILS_TIMER_H

/*
 * create a timer file description
 *
 * RETURN VALUE
 *	if success, return timerfd
 *	while over max retries, return -2 indicating timer create failed
 *
 */
int lnxutil_timer_create(void);

int lnxutil_timer_delete(int tfd);

/*
 * configure timer by opened timerfd, unit ms
 *
 * DESCRIPTION
 *  tfd: timer file description
 *  interval: the period, while `interval == -1', timer will trigger only once
 *
 * RETURN VALUE
 *	if success, return 0
 *	when error occurrd, return -1 and you can find the cause by errno
 *
 */
int lnxutil_timer_set_ms(int tfd, int start, int interval);

int lnxutil_timer_set(int tfd, int start_sec, int interval);

int lnxutil_timer_set2(int tfd, int start_sec);

/*
 * RETURN VALUE
 *	if success, return times of trigger
 *	when error occurrd, return -1
 *
 */
int lnxutil_timer_read(int tfd);


#endif
