Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Learning Concurrency in Kotlin

You're reading from   Learning Concurrency in Kotlin Build highly efficient and scalable applications

Arrow left icon
Product type Paperback
Published in Jul 2018
Publisher Packt
ISBN-13 9781788627160
Length 266 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
 Castiblanco Torres Castiblanco Torres
Author Profile Icon Castiblanco Torres
Castiblanco Torres
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
1. Hello, Concurrent World! FREE CHAPTER 2. Coroutines in Action 3. Life Cycle and Error Handling 4. Suspending Functions and the Coroutine Context 5. Iterators, Sequences, and Producers 6. Channels - Share Memory by Communicating 7. Thread Confinement, Actors, and Mutexes 8. Testing and Debugging Concurrent Code 9. The Internals of Concurrency in Kotlin 1. Other Books You May Enjoy Index

Index

A

  • actors
    • about / Actors, What is an actor?
    • creating / Creating an actor
    • used, for extending functionality / Using actors to extend the functionality
    • interactions / More on actor interaction
    • buffered actors / Buffered actors
    • with CoroutineContext / Actor with CoroutineContext
    • CoroutineStart / CoroutineStart
    • working / Actors in action
    • label, adding to UI / Adding the label to the UI
    • creation, for using as counter / Creating an actor to use as a counter
    • counter, increasing as results are loaded / Increasing the counter as results are loaded
    • channel, adding / Adding a channel so that the UI reacts to updates
    • updated value, sending through channel / Sending the updated value through the channel
    • UI, updating on changes / Updating the UI on changes
    • implementation, testing / Testing the implementation
    • extending, for counter reset / Extending the actor to allow for resetting the counter
    • counters, resetting upon searches / Resetting the counter upon new searches
  • adapter
    • used, for mapping information / Adapter to map the information
    • ViewHolder, adding / Adding a ViewHolder
    • data, mapping / Mapping the data
    • incremental addition of articles, allowing / Allowing the incremental addition of articles to the adapter
    • connecting, to activity / Connecting the adapter to the activity
  • adapter data, mapping
    • onCreateViewHolder / onCreateViewHolder
    • onBindViewHolder / onBindViewHolder
    • getItemCount / getItemCount
  • Android's UI thread
    • about / Android's UI thread
    • CalledFromWrongThreadException / CalledFromWrongThreadException
    • NetworkOnMainThreadException / NetworkOnMainThreadException
    • updating / Requesting in the background, updating in the UI thread
  • Android Studio
    • downloading / Downloading and installing Android Studio
    • reference / Downloading and installing Android Studio
    • installing / Downloading and installing Android Studio
  • application
    • exception, significance / Don't ignore the exception!
  • ArrayChannel / ArrayChannel
  • asynchronous function
    • creating / Creating an asynchronous function to hold the request... or not
    • synchronous function, wrapped in asynchronous caller / A synchronous function wrapped in an asynchronous caller
    • with predefined dispatcher / An asynchronous function with a predefined dispatcher
    • with flexible dispatcher / An asynchronous function with a flexible dispatcher
    • options, selecting / How to decide which option is better
    • about / Job and Deferred
    • versus suspending functions / Suspending functions versus async functions
  • atomic data structures / Atomic data structures
  • atomicity violation
    • avoiding / Atomicity violation
    • atomicity / What atomicity means

B

  • backpressure / Types of channels and backpressure
  • buffered actors / Buffered actors
  • buffered channels
    • about / Buffered channels
    • LinkedListChannel / LinkedListChannel
    • ArrayChannel / ArrayChannel
    • ConflatedChannel / ConflatedChannel

C

  • CancellationException / CancellationException
  • channels
    • about / Understanding channels
    • examples / Understanding channels
    • types / Types of channels and backpressure
    • unbuffered channels / Unbuffered channels
    • buffered channels / Buffered channels
    • interacting with / Interacting with channels
    • SendChannel / SendChannel
    • working / Channels in action
    • search activity, adding / Adding a search activity
    • search function, adding / Adding the search function
    • collaborative search, implementing / Implementing the collaborative search
    • search functions, connecting / Connecting the search functions
    • ArticleAdapter, updating / Updating ArticleAdapter
    • results, displaying / Displaying the results
  • concurrency
    • about / Introduction to concurrency, Why concurrency is often feared
    • versus parallelism / Concurrency is not parallelism
    • race conditions / Race conditions
    • atomicity violation / Atomicity violation
    • deadlocks / Deadlocks
    • livelocks / Livelocks
    • in Kotlin / Concurrency in Kotlin
  • concurrency, versus parallelism
    • in CPU-bound algorithms / Concurrency versus parallelism in CPU-bound algorithms
    • in I/O-bound algorithms / Concurrency versus parallelism in I/O-bound algorithms
  • concurrent code
    • testing / Testing concurrent code
  • ConflatedChannel / ConflatedChannel
  • contexts
    • about / More about contexts
    • mixing / Mixing contexts
    • combining / Combining contexts
    • separating / Separating contexts
    • used, for temporary context switch / Temporary context switch using withContext
  • context switching
    • about / Context switching
    • thread switching / Thread switching
    • exception handling / Exception handling
    • platform specific logic / Platform specific logic
  • ContinuationInterceptor
    • about / ContinuationInterceptor
    • CommonPool / CommonPool
    • Unconfined / Unconfined
    • Android's UI / Android's UI
  • Continuation Passing Style (CPS)
    • about / Continuation Passing Style
    • continuations / Continuations
    • suspend modifier / The suspend modifier
    • state machine / State machine
  • coroutine
    • about / Processes, threads, and coroutines, Coroutines
    • support, adding / Adding support for coroutines
    • attaching, to dispatcher / Attaching a coroutine to a dispatcher
    • initiating, with async / Starting a coroutine with async
    • starting, with async / Starting a coroutine with async
    • initiating, with launch / Starting a coroutine with launch
    • dispatcher, using / Using a specific dispatcher when starting the coroutine
    • creating, to call service / Creating a coroutine to call a service
    • identifying, in logs / Identifying a coroutine in the logs
    • identifying in logs, with automatic naming / Using automatic naming
    • identifying in logs, by setting specific name / Setting a specific name
    • identifying in debugger, with debugger watch / Adding a debugger watch
    • identifying in debugger, with conditional breakpoint / Conditional breakpoint
  • coroutine context
    • about / The coroutine context
    • dispatcher / Dispatcher
    • exception handling / Exception handling
    • non-cancellable / Non-cancellable
  • CoroutineDispatcher / CoroutineDispatcher
  • CoroutineExceptionHandler / CoroutineExceptionHandler
  • CPU-bound algorithms
    • about / CPU-bound
    • concurrency, versus parallelism / Concurrency versus parallelism in CPU-bound algorithms
    • single-core execution / Single-core execution
    • parallel execution / Parallel execution

D

  • debugging
    • about / Debugging
    • coroutine, identifying in logs / Identifying a coroutine in the logs
    • coroutine, identifying in debugger / Identifying a coroutine in the debugger
  • default dispatcher / Default dispatcher
  • deferred
    • about / Deferred
    • exception handling / Exception handling
    • unexpected crash / Non-happy path – Unexpected crash
    • exception, storing / Having deferred store the exception
  • DispatchedContinuation / DispatchedContinuation
  • DispatchedTask / DispatchedTask
  • dispatcher / Dispatcher

E

  • element functions, suspending sequences
    • elementAt / elementAt
    • elementAtOrElse / elementAtOrElse
    • elementAtOrNull / elementAtOrNull
  • exception handling / Exception handling
  • exceptions, coroutines
    • handleCoroutineException() function / The handleCoroutineException() function
    • CoroutineExceptionHandler / CoroutineExceptionHandler
    • CancellationException / CancellationException

F

  • Fibonacci sequence
    • writing / Writing a Fibonacci sequence
    • suspending, with producer / Suspending a Fibonacci sequence using a producer
  • functional tests
    • writing / Writing Functional Tests, Writing the tests
    • flawed UserManager, creating / Creating a flawed UserManager
    • kotlin-test library, adding / Adding the kotlin-test library
    • happy path test, adding / Adding a happy path test
    • test, for edge case / Testing for an edge case
    • issue, identifying / Identifying the issue
    • crash, fixing / Fixing the crash
    • retesting / Retesting

H

  • handleCoroutineException() function / The handleCoroutineException() function

I

  • I/O-bound algorithms
    • about / I/O-bound
    • concurrency, versus parallelism in / Concurrency versus parallelism in I/O-bound algorithms

J

  • job
    • about / Job
    • exception handling / Exception handling
    • lifecycle / Life cycle
    • states / Life cycle, States move in one direction only
    • current state, determining / Determining the current state of a Job
    • cancelling / Cancelling the job

K

  • Kotlin
    • concurrency / Concurrency in Kotlin
    • non-blocking / Non-blocking
    • explicit / Being explicit
    • readable / Readable
    • leveraged / Leveraged
    • flexible / Flexible
    • concepts / Concepts and terminology
    • computations, suspending / Suspending computations
    • functions, suspending / Suspending functions
    • suspending lambdas / Suspending lambdas
    • coroutine dispatcher / Coroutine dispatcher
    • coroutine builders / Coroutine builders
  • Kotlin project
    • creating / Creating a Kotlin project

L

  • LinkedListChannel / LinkedListChannel

M

  • mutexes
    • creating / Creating mutexes
  • mutual exclusions
    • about / Mutual exclusions, Understanding mutual exclusions
    • mutexes, creating / Creating mutexes
    • interacting / Interacting with mutual exclusions

N

  • networking permissions
    • adding / Adding networking permissions

O

  • offering elements, SendChannel
    • on channel closed / On channel closed
    • on channel full / On channel full
    • on channel open and not full / On channel open and not full

P

  • parallelism
    • versus concurrency / Concurrency is not parallelism
  • platform-specific UI libraries
    • about / Platform-specific UI libraries
    • dependency, adding / Adding the dependency
    • Android's UI coroutine dispatcher, using / Using Android's UI coroutine dispatcher
  • platform specific logic
    • JVM / JVM
    • JavaScript / JavaScript
  • processes / Processes, threads, and coroutines, Processes
  • producer
    • about / Producers
    • creating / Creating a producer
    • interacting with / Interacting with a producer
    • elements, reading / Reading all the elements in the producer
    • single element, receiving / Receiving a single element
    • group of elements, selecting / Taking a group of elements
    • multiple elements, selecting / Taking more elements than those available
    • used, for suspending Fibonacci sequence / Suspending a Fibonacci sequence using a producer
    • working with / Producers in action
    • adapter, used for requesting articles / Having the adapter request more articles
    • creating, that fetches feeds / Creating a producer that fetches feeds on demand
    • articles, adding to list on UI / Adding the articles to the list on the UI

R

  • ReceiveChannel
    • validation before receiving / Validating before reading
    • isClosedForReceive / isClosedForReceive
    • isEmpty / isEmpty
  • RendezvousChannel / RendezvousChannel
  • resiliency / Resiliency and stability
  • RSS
    • about / RSS – Reading from multiple feeds concurrently
    • list of feeds, supporting / Supporting a list of feeds
    • thread pool, creating / Creating a thread pool
    • data, fetching concurrently / Fetching the data concurrently
    • responses, merging / Merging the responses
    • concurrent requests, testing / Testing the concurrent requests
  • RSS Reader UI
    • enhancing / Improving the UI of the RSS Reader
    • feed, naming / Giving each feed a name
    • articles information, fetching from feed / Fetching more information about the articles from the feed
    • scrollable list, adding for articles / Adding a scrollable list for the articles
    • layout, used for individual articles / Layout for the individual articles
    • adapter, used for mapping information / Adapter to map the information
    • adapter, connecting to activity / Connecting the adapter to the activity
    • testing / Testing the new UI
    • data, sanitizing / Sanitizing the data

S

  • SendChannel
    • about / SendChannel
    • validations, before sending elements / Validating before sending
    • elements, sending / Sending elements
    • offering elements / Offering elements
  • sequences
    • about / Sequences
    • interacting with / Interacting with a sequence
    • elements, reading in sequence / Reading all the elements in the sequence
    • specific element, obtaining / Obtaining a specific element
    • group of elements, obtaining / Obtaining a group of elements
    • stateless sequences / Sequences are stateless
  • stability / Resiliency and stability
  • state machine, Continuation Passing Style (CPS)
    • labels / Labels
    • continuations / Continuations
    • callbacks / Callbacks
    • label, incrementing / Incrementing the label
    • result, storing from other operations / Storing the result from the other operations
    • result, returning of suspending computation / Returning the result of the suspending computation
  • states, job
    • new / New
    • active / Active
    • canceling / Canceling
    • cancelled / Cancelled
    • completed / Completed
  • suspendable iterators
    • about / Suspendable sequences and iterators, Iterators
    • using / Interacting with an iterator
    • elements / Going through all the elements
    • next value, obtaining / Getting the next value
    • elements, validating / Validating whether there are more elements
    • next(), calling without validating elements / Calling next() without validating for elements
    • hasNext(), working / A note on the inner working of hasNext()
  • suspendable sequences
    • about / Suspendable sequences and iterators
    • values, yielding / Yielding values
  • suspending Fibonacci
    • about / Suspending Fibonacci
    • Fibonacci sequence, writing / Writing a Fibonacci sequence
    • Fibonnaci iterator, writing / Writing a Fibonnaci iterator
  • suspending functions
    • about / Suspending functions
    • working with / Suspending functions in action
    • repository, writing with async functions / Writing a repository with async functions
    • upgrading / Upgrading to suspending functions
    • versus async functions / Suspending functions versus async functions
  • suspending lambda / Suspending functions

T

  • temporary context switch
    • using, with contexts / Temporary context switch using withContext
  • Test-Driven Development (TDD) / Creating a flawed UserManager
  • tests
    • considerations / More advice on tests
  • TextView
    • amount of news, displaying / Displaying the amount of news that were processed
  • thread
    • about / Processes, threads, and coroutines, Threads
    • creating / Creating a thread
    • CoroutineDispatcher / CoroutineDispatcher
    • coroutine, attaching to dispatcher / Attaching a coroutine to a dispatcher
  • thread cache / Thread cache
  • thread confinement
    • about / Thread confinement, What is thread confinement?
    • coroutines, confining to single thread / Confining coroutines to a single thread
  • thread switching
    • about / Thread switching
    • ContinuationInterceptor / ContinuationInterceptor, CoroutineDispatcher
    • DispatchedContinuation / DispatchedContinuation
    • DispatchedTask / DispatchedTask
  • types, dispatcher
    • CommonPool / CommonPool
    • unconfined / Unconfined
    • single thread context / Single thread context
    • thread pool / Thread pool

U

  • UI dispatcher
    • using / Using a UI dispatcher
    • platform-specific UI libraries / Platform-specific UI libraries
  • UI elements
    • adding / Adding UI elements
    • blocked / What happens when the UI is blocked
  • unbuffered channels
    • about / Unbuffered channels
    • RendezvousChannel / RendezvousChannel
  • use case, channels
    • data streaming / Use case – streaming data
    • work distribution / Use case – distributing work

V

  • @Volatile
    • about / @Volatile
    • using / When to use @Volatile
  • volatile variables
    • about / Volatile variables
    • thread cache / Thread cache
    • @Volatile / @Volatile
    • misconceptions / Why @Volatile doesn't solve thread-safe counters
    • @Volatile, using / When to use @Volatile
lock icon The rest of the chapter is locked
arrow left Previous Section
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images