Time, Time, Time

When dealing with real-world code, you frequently need to interact with time, whether having calls time out after awhile or scheduling things to happen at specific times. GCD calls these times temporal milestones, and they are represented by a dispatch_time_t. This type is a semi-opaque integer; it has an integer value, but its contents are subject to change. Time can be expressed relative to another time or relative to two distinguished moments in time – now and forever:

s​t​a​t​i​c​ ​c​o​n​s​t​ ​d​i​s​p​a​t​c​h​_​t​i​m​e​_​t​ ​D​I​S​P​A​T​C​H​_​T​I​M​E​_​N​O​W​ ​=​ ​0​;​
s​t​a​t​i​c​ ​c​o​n​s​t​ ​d​i​s​p​a​t​c​h​_​t​i​m​e​_​t​ ​D​I​S​P​A​T​C​H​_​T​I​M​E​_​F​O​R​E​V​E​R​ ​=​ ​~​0​u​l​l​;​

Use DISPATCH_TIME_FOREVER for an ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.