Skip to content

Instantly share code, notes, and snippets.

SreenivasulaReddy sreeram780

  • Hyderabad
View GitHub Profile
@sreeram780
sreeram780 / Semaphore.swift
Created Mar 1, 2018 — forked from jhanzo/Semaphore.swift
Quick overview about semaphores
View Semaphore.swift
//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()
You can’t perform that action at this time.