dispatch_after.3 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. .\" Copyright (c) 2008-2010 Apple Inc. All rights reserved.
  2. .Dd May 1, 2009
  3. .Dt dispatch_after 3
  4. .Os Darwin
  5. .Sh NAME
  6. .Nm dispatch_after
  7. .Nd schedule blocks for deferred execution
  8. .Sh SYNOPSIS
  9. .Fd #include <dispatch/dispatch.h>
  10. .Ft void
  11. .Fo dispatch_after
  12. .Fa "dispatch_time_t when" "dispatch_queue_t queue" "void (^block)(void)"
  13. .Fc
  14. .Ft void
  15. .Fo dispatch_after_f
  16. .Fa "dispatch_time_t when" "dispatch_queue_t queue" "void *context" "void (*function)(void *)"
  17. .Fc
  18. .Sh DESCRIPTION
  19. The
  20. .Fn dispatch_after
  21. function submits the
  22. .Fa block
  23. to the given
  24. .Fa queue
  25. at the time specified by the
  26. .Fa when
  27. parameter.
  28. The
  29. .Fa when
  30. parameter is a value created by
  31. .Fn dispatch_time
  32. or
  33. .Fn dispatch_walltime .
  34. Submission of the block may be delayed by the system in order to improve power consumption and system performance.
  35. The system applies a leeway (see
  36. .Xr dispatch_source_set_timer 3 )
  37. that is equal to one tenth of the interval between
  38. .Fa when
  39. and the time at which the function is called, with the leeway capped to at least one millisecond and at most one minute.
  40. .Pp
  41. For a more detailed description about submitting blocks to queues, see
  42. .Xr dispatch_async 3 .
  43. .Sh CAVEATS
  44. .Fn dispatch_after
  45. retains the passed queue.
  46. .Pp
  47. Specifying
  48. .Vt DISPATCH_TIME_NOW
  49. as the
  50. .Fa when
  51. parameter
  52. is supported, but is not as efficient as calling
  53. .Fn dispatch_async .
  54. .Pp
  55. The result of passing
  56. .Vt DISPATCH_TIME_FOREVER
  57. as the
  58. .Fa when
  59. parameter is undefined.
  60. .Pp
  61. .Sh FUNDAMENTALS
  62. The
  63. .Fn dispatch_after
  64. function is a wrapper around
  65. .Fn dispatch_after_f .
  66. .Sh SEE ALSO
  67. .Xr dispatch 3 ,
  68. .Xr dispatch_async 3 ,
  69. .Xr dispatch_time 3