0 votes
in Technology by (438k points)

How does dispatch_once manages to run only once?

1 Answer

0 votes
by (438k points)
dispatch_once() is synchronous process and all GCD methods do things asynchronously (case in point, dispatch_sync() is synchronous)
The entire idea of dispatch_once() is “perform something once and only once”, which is precisely what we’re doing. dispatch_once that’s used to guarantee that something happens exactly once, no matter how violent the program’s threading becomes.

Related questions

...