Fix a spell miss of document.
[AGL/documentation.git] / docs / 3_Developer_Guides / 4_AFB_Helper_Guide / 2_AFB_Timer.md
1 ---
2 title: AFB Timer functions
3 ---
4
5 ## TimerHandleT
6
7 Members are:
8
9 * `count`: integer representing the number of times the timers should run.
10 * `delay`: millisecond integer representing the delay to wait before and between
11  the callback run.
12 * `uid`: a string identifying the timer.
13 * `context`: an opaq pointer that could be used in the callback function.
14 * `evtSource`: a systemd event source struct. Should be NULL.
15 * `api`: the AFB api pointer.
16 * `callback`: a function pointer for the callback to call at timer expiration
17 * `freeCB`: a function pointer called after expiration of the timer. Mainly meant
18  to release the context pointer by example.
19
20 ## void TimerEvtStart(afb_api_t api, TimerHandleT *timerHandle, timerCallbackT callback, void *context)
21
22 Start a timer which invokes the callback when the delay expires for `count`
23 times.
24
25 * `api`: AFB api pointer.
26 * `timerHandle`: pointer to struct representing a timer.
27 * `callback`: a function pointer for the callback to call at timer expiration
28 * `context`: an opaq pointer that could be used in the callback function.
29
30 ## void TimerEvtStop(TimerHandleT *timerHandle)
31
32 Manually stop the timer's run. If the `count` isn't finished then it will end
33 the timer and no other runs will occur.
34
35 * `timerHandle`: pointer to struct representing a timer.
36
37 ## uint64_t LockWait(afb_api_t api, uint64_t utimeout)
38
39 It is function acting like a non-blocking sleep for an API. It lets the main API
40 event loop runs while you are waiting and will unlock at the first received
41 event and returns the remaining time to wait if an event occurs or 0 if no events
42 occured and timeout hits. Then you have to manually ensure that once an event
43 has been received that it was the one you are waiting for and if not launch again
44 the wait with the remaining time returned.
45
46 * `api`: AFB api pointer.
47 * `timeout`: timeout in microsecond.
48
49 Returns the remaining time in microsecond to wait if an event occurs or 0 if no
50 events occured and timeout hits.