Skip to content

Instantly share code, notes, and snippets.

@lattner
lattner / async_swift_proposal.md
Last active April 21, 2024 09:43 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

@vermotr
vermotr / upgrade.sh
Created April 28, 2016 11:24
Bash script to upgrade docker container after its image changed
#!/usr/bin/env bash
if [ $# -lt 1 ];then
echo Usage: `basename $0` image 1>&2
exit 1
fi
set -e
IMAGE=$1
CID=$(docker ps | grep $IMAGE | awk '{print $1}')
@nbhasin2
nbhasin2 / Thread_management_iOS.swift
Created January 20, 2015 21:53
Multi Threading in Swift (iOS) using Dispatch Group
//Group 4 will be executed last after 1-3 are done executing
//Multi Threadin in Swift Group Dispatch Example
//Global Dispatch Queue
let dispatchGroup = dispatch_group_create()
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), {