in Technology by (1.8m points)

How does dispatch_once manages to run only once?

1 Answer

0 votes
by (1.8m 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

0 votes
asked Apr 21, 2021 in Technology by JackTerrance (1.8m points)