Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

retry.h 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef _GPXE_RETRY_H
  2. #define _GPXE_RETRY_H
  3. /** @file
  4. *
  5. * Retry timers
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER );
  9. #include <gpxe/list.h>
  10. /** Default timeout value */
  11. #define DEFAULT_MIN_TIMEOUT ( TICKS_PER_SEC / 4 )
  12. /** Limit after which the timeout will be deemed permanent */
  13. #define DEFAULT_MAX_TIMEOUT ( 10 * TICKS_PER_SEC )
  14. /** A retry timer */
  15. struct retry_timer {
  16. /** List of active timers */
  17. struct list_head list;
  18. /** Timer is currently running */
  19. unsigned int running;
  20. /** Timeout value (in ticks) */
  21. unsigned long timeout;
  22. /** Minimum timeout value (in ticks)
  23. *
  24. * A value of zero means "use default timeout."
  25. */
  26. unsigned long min_timeout;
  27. /** Maximum timeout value before failure (in ticks)
  28. *
  29. * A value of zero means "use default timeout."
  30. */
  31. unsigned long max_timeout;
  32. /** Start time (in ticks) */
  33. unsigned long start;
  34. /** Retry count */
  35. unsigned int count;
  36. /** Timer expired callback
  37. *
  38. * @v timer Retry timer
  39. * @v fail Failure indicator
  40. *
  41. * The timer will already be stopped when this method is
  42. * called. The failure indicator will be True if the retry
  43. * timeout has already exceeded @c MAX_TIMEOUT.
  44. */
  45. void ( * expired ) ( struct retry_timer *timer, int over );
  46. };
  47. extern void start_timer ( struct retry_timer *timer );
  48. extern void start_timer_fixed ( struct retry_timer *timer,
  49. unsigned long timeout );
  50. extern void stop_timer ( struct retry_timer *timer );
  51. /**
  52. * Start timer with no delay
  53. *
  54. * @v timer Retry timer
  55. *
  56. * This starts the timer running with a zero timeout value.
  57. */
  58. static inline void start_timer_nodelay ( struct retry_timer *timer ) {
  59. start_timer_fixed ( timer, 0 );
  60. }
  61. /**
  62. * Test to see if timer is currently running
  63. *
  64. * @v timer Retry timer
  65. * @ret running Non-zero if timer is running
  66. */
  67. static inline __attribute__ (( always_inline )) unsigned long
  68. timer_running ( struct retry_timer *timer ) {
  69. return ( timer->running );
  70. }
  71. #endif /* _GPXE_RETRY_H */