aboutsummaryrefslogtreecommitdiffstats
path: root/docs/afb-timer.md
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-01-04 14:31:42 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2019-01-16 08:45:56 +0000
commitb7e6dbef56913fa43ea23b842ebe2933d9e0477e (patch)
tree06292d4cbc5acf1eb8da4ca9eabec10dafc274b3 /docs/afb-timer.md
parent2e36a74fa8ae2a4b8e06f7752c3876f32a8dcbb3 (diff)
Add functions reference documentationguppy_6.99.4guppy/6.99.46.99.4
Only JSON helpers functions were documented before this commits. This add a description for every function of the afb-helpers library. Bug-AGL: SPEC-2114 Change-Id: I3ae941841ef4ad8e345dd4cd6bc012f6596eadc2 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'docs/afb-timer.md')
-rw-r--r--docs/afb-timer.md48
1 files changed, 48 insertions, 0 deletions
diff --git a/docs/afb-timer.md b/docs/afb-timer.md
new file mode 100644
index 0000000..d02ab69
--- /dev/null
+++ b/docs/afb-timer.md
@@ -0,0 +1,48 @@
+# AFB Timer functions reference
+
+## 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