O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required