You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

retry.h 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef _GPXE_RETRY_H
  2. #define _GPXE_RETRY_H
  3. /** @file
  4. *
  5. * Retry timers
  6. *
  7. */
  8. #include <gpxe/list.h>
  9. /** A retry timer */
  10. struct retry_timer {
  11. /** List of active timers */
  12. struct list_head list;
  13. /** Timeout value (in ticks) */
  14. unsigned long timeout;
  15. /** Start time (in ticks)
  16. *
  17. * A start time of zero indicates a stopped timer.
  18. */
  19. unsigned long start;
  20. /** Retry count */
  21. unsigned int count;
  22. /** Timer expired callback
  23. *
  24. * @v timer Retry timer
  25. * @v fail Failure indicator
  26. *
  27. * The timer will already be stopped when this method is
  28. * called. The failure indicator will be True if the retry
  29. * timeout has already exceeded @c MAX_TIMEOUT.
  30. */
  31. void ( * expired ) ( struct retry_timer *timer, int over );
  32. };
  33. extern void start_timer ( struct retry_timer *timer );
  34. extern void stop_timer ( struct retry_timer *timer );
  35. /**
  36. * Test to see if timer is currently running
  37. *
  38. * @v timer Retry timer
  39. * @ret running Non-zero if timer is running
  40. */
  41. static inline __attribute__ (( always_inline )) unsigned long
  42. timer_running ( struct retry_timer *timer ) {
  43. return ( timer->start );
  44. }
  45. #endif /* _GPXE_RETRY_H */