This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In iOS, Grand Central Dispatch brings some utilities for using asynchronous tasks | |
//Among all functionalities, there is Semaphore which is an old school theory thought by Djikstra | |
//More info here : https://en.wikipedia.org/wiki/Semaphore_(programming) | |
//Semaphores give a control access to a common resource through concurrent tasks (done in other threads) | |
//NB 1: in iOS, all UI jobs has to be done ONLY in main thread, otherwise a fatal error occurs | |
//NB 2: before using semaphore in iOS you should always wonder if dispatch_group is not enough | |
//NB 3: for doing an async task in your playground you have to use semaphore concept or at least this two kinds of methods : | |
// XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
// XCPlaygroundPage.currentPage.finishExecution() |