diff options
author | Shankho Boron Ghosh <shankhoghosh123@gmail.com> | 2020-11-30 03:44:47 +0530 |
---|---|---|
committer | Shankho Boron Ghosh <shankhoghosh123@gmail.com> | 2020-11-29 23:20:37 +0000 |
commit | 5727bbb99921a741ee7203a070f580a026f37bc8 (patch) | |
tree | d92b1d1d61fb3e9e3ca7b7fac7e521ad2c35e40a /docs/3_Developer_Guides/4_AFB_Helper_Guide/2_AFB_Timer.md | |
parent | e5e292979e4a08e036e6545d55dd8515a8b6c280 (diff) |
Added AFB Helper Guide in Developer Guides
Revised and added AFB Helper Guide as a part of Developer Guides.
Bug-AGL: [SPEC-3633]
Signed-off-by: Shankho Boron Ghosh <shankhoghosh123@gmail.com>
Change-Id: I3df9265ae0570e987d80bc4bd2d3d14e7743b26a
Diffstat (limited to 'docs/3_Developer_Guides/4_AFB_Helper_Guide/2_AFB_Timer.md')
-rw-r--r-- | docs/3_Developer_Guides/4_AFB_Helper_Guide/2_AFB_Timer.md | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/docs/3_Developer_Guides/4_AFB_Helper_Guide/2_AFB_Timer.md b/docs/3_Developer_Guides/4_AFB_Helper_Guide/2_AFB_Timer.md new file mode 100644 index 0000000..3af5385 --- /dev/null +++ b/docs/3_Developer_Guides/4_AFB_Helper_Guide/2_AFB_Timer.md @@ -0,0 +1,50 @@ +--- +title: AFB Timer functions +--- + +## TimerHandleT + +Members are: + +* `count`: integer representing the number of times the timers should run. +* `delay`: millisecond integer representing the delay to wait before and between + the callback run. +* `uid`: a string identifying the timer. +* `context`: an opaq pointer that could be used in the callback function. +* `evtSource`: a systemd event source struct. Should be NULL. +* `api`: the AFB api pointer. +* `callback`: a function pointer for the callback to call at timer expiration +* `freeCB`: a function pointer called after expiration of the timer. Mainly meant + to release the context pointer by example. + +## void TimerEvtStart(afb_api_t api, TimerHandleT *timerHandle, timerCallbackT callback, void *context) + +Start a timer which invokes the callback when the delay expires for `count` +times. + +* `api`: AFB api pointer. +* `timerHandle`: pointer to struct representing a timer. +* `callback`: a function pointer for the callback to call at timer expiration +* `context`: an opaq pointer that could be used in the callback function. + +## void TimerEvtStop(TimerHandleT *timerHandle) + +Manually stop the timer's run. If the `count` isn't finished then it will end +the timer and no other runs will occur. + +* `timerHandle`: pointer to struct representing a timer. + +## uint64_t LockWait(afb_api_t api, uint64_t utimeout) + +It is function acting like a non-blocking sleep for an API. It lets the main API +event loop runs while you are waiting and will unlock at the first received +event and returns the remaining time to wait if an event occurs or 0 if no events +occured and timeout hits. Then you have to manually ensure that once an event +has been received that it was the one you are waiting for and if not launch again +the wait with the remaining time returned. + +* `api`: AFB api pointer. +* `timeout`: timeout in microsecond. + +Returns the remaining time in microsecond to wait if an event occurs or 0 if no +events occured and timeout hits.
\ No newline at end of file |