Skip to content

Commit f032f6f

Browse files
committedFeb 20, 2018
feat(timer): add LCUITimer_SetTimeout() and LCUITimer_SetInterval()
1 parent ef66d4f commit f032f6f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
 

‎include/LCUI/timer.h

+10
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ LCUI_BEGIN_HEADER
4949
LCUI_API int LCUITimer_Set( long int n_ms, void (*callback_func)(void*),
5050
void *arg, LCUI_BOOL reuse );
5151

52+
/** repeatedly calls a function, with a fixed time delay between each call. */
53+
LCUI_API int LCUITimer_SetTimeout( long int n_ms,
54+
void( *callback )(void*),
55+
void *arg );
56+
57+
/** set a timer which execute a function once after the timer expires. */
58+
LCUI_API int LCUITimer_SetInterval( long int n_ms,
59+
void( *callback )(void*),
60+
void *arg );
61+
5262
/**
5363
* 释放定时器
5464
* 当不需要定时器时,可以使用该函数释放定时器占用的资源,并移除程序任务队列

‎src/timer.c

+14
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,20 @@ int LCUITimer_Set( long int n_ms, void (*func)(void*),
200200
return timer->id;
201201
}
202202

203+
int LCUITimer_SetTimeout( long int n_ms,
204+
void( *callback )(void*),
205+
void *arg )
206+
{
207+
return LCUITimer_Set( n_ms, callback, arg, FALSE );
208+
}
209+
210+
int LCUITimer_SetInterval( long int n_ms,
211+
void( *callback )(void*),
212+
void *arg )
213+
{
214+
return LCUITimer_Set( n_ms, callback, arg, TRUE );
215+
}
216+
203217
int LCUITimer_Free( int timer_id )
204218
{
205219
Timer timer;

0 commit comments

Comments
 (0)