Giter Site home page Giter Site logo

first-step-swift-concurrency's Introduction

「Swift Concurrency入門」サンプルコード

本リポジトリは書籍「Swift Concurrency入門」のサンプルコードを提供するリポジトリです。

「Swift Concurrency入門」はSwift 5.5から登場したSwift Concurrencyを解説する技術本です。 Swift Concurrencyの概念はもちろん、async/awaitActor@MainActorTaskAsyncSequenceSendableといったSwift Concurrencyを利用する上で欠かせない型の使い方や、以前のコードとSwift Concurrencyのコードがどのように異なるのかの比較も紹介しています。

「Swift Concurrency入門」は同人版と商業版があります。 どちらもサンプルコードは本リポジトリで管理します。

サンプルコードの改定や本文の改定・誤字修正も本リポジトリでお知らせします。

Book URL

目次

【第一章 async/await】

非同期処理をasync/awaitで記述できるようになりました。従来クロージャーによるコールバックと比べてどのように簡潔、安全になったのかを解説します。

サンプルコード1

サンプルコード2

【第二章 Actor/データ競合を守る新しい型】

マルチスレッドプログラミングにおいて、データ競合(data race)は典型的な不具合のひとつです。Swift Concurrencyではデータ競合を防ぐ新しい型、Actorが導入されました。どのような特徴があるのかを解説します。

サンプルコード

【第三章 AsyncSequence】

繰り返し処理でお馴染みのfor文を非同期で書きましょう。

for await inループとそれを実現するAsyncSequenceプロトコルを学びます。

サンプルコード

【第四章 Task】

Swift Concurrencyの並行処理はTaskという単位で行われます。Taskの特徴を解説します。

サンプルコード

【第五章 Sendable】

Actorを始め、並行コードにおいて、データ競合なしにデータを同時並行処理間で渡せるかどうかを表す新しいプロトコルSendableが登場しました。Sendableを解説し、コンパイラがエラーを出力した場合の対処方法を探ります。

サンプルコード

【第六章 既存のプロジェクトにSwift Concurrencyを導入】

既存のプロジェクトにSwift Concurrencyを導入する方法を解説します。async/await@MainActorだけでなく、Swift 5.6の対応も行います。

サンプルコード

ライセンス

本サンプルコードはMITで配布しています。 詳細はこちらをご覧ください。

Pull Requestやissueについて

サンプルコード自体の疑問や改善点があれば、ぜひPull Requestやissueの作成をお願いします。 ただし、書籍上、解説のためにわざとワーニングを出している箇所があるので予めご了承ください。

書籍本文自体の疑問があれば下記メールアドレスにまでご連絡ください。

サンプルコード履歴

releaseページをご覧ください。

https://github.com/SatoTakeshiX/first-step-swift-concurrency/releases

first-step-swift-concurrency's People

Contributors

satotakeshix avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.