Share E-Book

Modern Concurrency in Swift (Marin Todorov)(Z-Library)

Author

Rating No ratings yet

Log in to rate

Mobile
Language English

No Description

Format EPUB
Size 24.9 MB
158
Views

AI Guide

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

Full assistant
AI guide
【One-Line Pitch】 A hands-on guide to Swift 5.5's native concurrency model—async/await, structured concurrency, actors, and async sequences—for intermediate Swift developers who want to write safer, more readable asynchronous code without wrestling with threads and GCD queues. 【Book Arc】 - **Opening (~0%–10%)**: Sets up the case for modern concurrency by contrasting synchronous, asynchronous, and concurrent execution, and diagnosing the pain points of the pre-5.5 world (thread explosion, priority inversion, lack of execution hierarchy). - **Early (~10%–35%)**: Introduces the four pillars of the new model—cooperative thread pool, async/await syntax, structured concurrency, and context-aware compilation—then gets you writing real code immediately in the LittleJohn stock-trading app. - **Middle (~35%–55%)**: Moves from single async calls to continuous data streams, using async sequences and `URLSession.bytes` to build a live price ticker, and touches on task cancellation within the structured hierarchy. - **Late (~55%–85%)**: Excerpts do not cover this range in detail; based on the introduction's promises, this is where deeper treatment of actors, task groups, and advanced error handling likely lives. - **Ending (~85%–100%)**: Excerpts do not cover this range; presumably wraps up with more complex real-world patterns and consolidation of the concurrency toolkit. 【Key Takeaways】 - **The new model abstracts away threads entirely** (Early): A cooperative thread pool sized to CPU cores replaces manual thread management, eliminating the create/destroy/switch overhead that plagued GCD-based code. - **async/await turns asynchronous code into something that reads like synchronous code** (Early): The `async` keyword marks a function as suspendable, and `await` creates a suspension point where the runtime can run other tasks before resuming—no more completion closures or capture-list gymnastics. - **Structured concurrency gives tasks a hierarchy** (Early): Every task has a parent and a priority; canceling a parent cancels its children, and high-priority tasks run before low-priority ones in the same hierarchy. This solves the "lack of execution hierarchy" problem that made GCD tasks hard to cancel or track. - **The compiler becomes a safety net** (Early): Context-aware compilation tracks whether code might run asynchronously and refuses to let you write unsafe mutations of shared state—this is what makes actors possible. - **Async sequences handle data that arrives over time** (Middle): Unlike a single `await` that returns one value, `URLSession.bytes` returns a sequence you iterate with `for try await`, making it suitable for live feeds like stock tickers that never "complete." - **Practical projects drive the learning** (Early–Middle): The LittleJohn app is built incrementally—first a simple symbol list fetch, then a live ticker—so each concept lands in a working context rather than in isolation. - **Platform requirements matter** (Early): Xcode 13.2+ bundles the concurrency runtime for iOS 13/macOS 10.15 targets; earlier Xcode 13 versions restrict you to iOS 15/macOS 12. Check your toolchain before starting. - **This is not a GCD book** (Opening): The author assumes you may not be proficient with pre-5.5 concurrency and explicitly does not teach it—the focus is entirely on the new native model. 【Reading Tips】 - **Deep-read the opening chapters even if you know GCD**: The comparison between the old and new models is the conceptual foundation for why structured concurrency exists; skimming it will make later chapters feel arbitrary. - **Type out the LittleJohn code yourself**: The book's pace is deliberately quick in the introduction, with brief API explanations. Running the code—especially the async sequence ticker—builds intuition that reading alone won't. - **Pay attention to compiler errors as teaching moments**: When Xcode complains about calling an async function from `onAppear`, that's the context-aware compiler doing its job. Understanding why `.task` works and `onAppear` doesn't is a core lesson. - **Don't skip the platform-version notes**: If you're targeting older OS versions, the Xcode version you use determines what you can ship. This is easy to overlook until build time. - **Treat the introduction as a map, not the territory**: The author explicitly says the nitty-gritty comes in later chapters. Use the early projects to get comfortable with syntax, then expect deeper treatment of actors and task groups later. 【Coverage Limits】 This guide is based on stratified excerpts covering roughly the first half of the book (through async sequences and the beginning of task cancellation). Later chapters on actors, task groups, and advanced patterns are not represented in the source material, so their specific content is not summarized here.

Passage locations

Excerpt 1
rior authorization. This book is for your personal use only. You are NOT allowed to sell this book without prior authorization, or distribute it to friends,...
View in text
Excerpt 2
ingle-lane road, each driving behind the one in front of it. Even if one vehicle has a higher priority, like an ambulance on duty, it cannot “jump over” the...
View in text
Excerpt 3
s to a web API to fetch JSON data, download images and more. The book comes with its own server app, called the book server for short, that you need to run i...
View in text
Excerpt 4
tTicker(selectedSymbols) } catch { lastErrorMessage = error.localizedDescription } } The code looks similar to what you did in SymbolListView , except that t...
View in text

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
← Back to List