idle_timeout.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include <inttypes.h>
  3. #include <stdbool.h>
  4. typedef struct IdleTimeoutContext IdleTimeoutContext;
  5. typedef bool (*IDLE_TIMEOUT_CALLBACK)(void* context);
  6. /**
  7. * @brief Initializes a new instance of IDLE timeout
  8. * @param timeout_sec IDLE timeout in seconds
  9. * @param on_idle_callback callback function to trigger when IDLE timeout happened
  10. * @param on_idle_callback_context callback function context
  11. * @return IDLE timeout context
  12. */
  13. IdleTimeoutContext* idle_timeout_alloc(uint16_t timeout_sec, IDLE_TIMEOUT_CALLBACK on_idle_callback, void* on_idle_callback_context);
  14. /**
  15. * @brief Starts IDLE timeout
  16. * @param context IDLE timeout context
  17. */
  18. void idle_timeout_start(IdleTimeoutContext* context);
  19. /**
  20. * @brief Stops IDLE timeout
  21. * @param context IDLE timeout context
  22. */
  23. void idle_timeout_stop(IdleTimeoutContext* context);
  24. /**
  25. * @brief Reports activity to IDLE timeout
  26. * @param context IDLE timeout context
  27. */
  28. void idle_timeout_report_activity(IdleTimeoutContext* context);
  29. /**
  30. * @brief Disposes IDLE timeout and releases all the resources
  31. * @param context IDLE timeout context
  32. */
  33. void idle_timeout_free(IdleTimeoutContext* context);