ua_timer.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef UA_TIMER_H_
  5. #define UA_TIMER_H_
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #include "ua_util.h"
  10. #include "ua_job.h"
  11. typedef void
  12. (*UA_RepeatedJobsListProcessCallback)(void *processContext, UA_Job *job);
  13. typedef struct {
  14. /* The linked list of jobs is sorted according to the execution timestamp. */
  15. SLIST_HEAD(RepeatedJobsSList, UA_RepeatedJob) repeatedJobs;
  16. /* Repeated jobs that shall be added or removed from the sorted list (with
  17. * atomic operations) */
  18. SLIST_HEAD(RepeatedJobsSList2, UA_RepeatedJob) addRemoveJobs;
  19. /* The callback to process jobs that have timed out */
  20. UA_RepeatedJobsListProcessCallback processCallback;
  21. void *processContext;
  22. } UA_RepeatedJobsList;
  23. void
  24. UA_RepeatedJobsList_init(UA_RepeatedJobsList *rjl,
  25. UA_RepeatedJobsListProcessCallback processCallback,
  26. void *processContext);
  27. UA_StatusCode
  28. UA_RepeatedJobsList_addRepeatedJob(UA_RepeatedJobsList *rjl, const UA_Job job,
  29. const UA_UInt32 interval, UA_Guid *jobId);
  30. UA_StatusCode
  31. UA_RepeatedJobsList_removeRepeatedJob(UA_RepeatedJobsList *rjl, const UA_Guid jobId);
  32. /* Process the repeated jobs that have timed out.
  33. * Returns the timestamp of the next scheduled repeated job. */
  34. UA_DateTime
  35. UA_RepeatedJobsList_process(UA_RepeatedJobsList *rjl, UA_DateTime nowMonotonic,
  36. UA_Boolean *dispatched);
  37. void
  38. UA_RepeatedJobsList_deleteMembers(UA_RepeatedJobsList *rjl);
  39. #ifdef __cplusplus
  40. } // extern "C"
  41. #endif
  42. #endif /* UA_TIMER_H_ */