售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Learning Concurrent Programming in Scala
Table of Contents
Learning Concurrent Programming in Scala
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
How this book is organized
What this book covers
What you need for this book
Installing the JDK
Installing and using SBT
Using Eclipse, IntelliJ IDEA, or another IDE
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Introduction
Concurrent programming
A brief overview of traditional concurrency
Modern concurrency paradigms
The advantages of Scala
Preliminaries
Execution of a Scala program
A Scala primer
Summary
Exercises
2. Concurrency on the JVM and the Java Memory Model
Processes and Threads
Creating and starting threads
Atomic execution
Reordering
Monitors and synchronization
Deadlocks
Guarded blocks
Interrupting threads and the graceful shutdown
Volatile variables
The Java Memory Model
Immutable objects and final fields
Summary
Exercises
3. Traditional Building Blocks of Concurrency
The Executor and ExecutionContext objects
Atomic primitives
Atomic variables
Lock-free programming
Implementing locks explicitly
The ABA problem
Lazy values
Concurrent collections
Concurrent queues
Concurrent sets and maps
Concurrent traversals
Creating and handling processes
Summary
Exercises
4. Asynchronous Programming with Futures and Promises
Futures
Starting future computations
Future callbacks
Futures and exceptions
Using the Try type
Fatal exceptions
Functional composition on futures
Promises
Converting callback-based APIs
Extending the future API
Cancellation of asynchronous computations
Futures and blocking
Awaiting futures
Blocking in asynchronous computations
The Scala Async library
Alternative Future frameworks
Summary
Exercises
5. Data-Parallel Collections
Scala collections in a nutshell
Using parallel collections
Parallel collection class hierarchy
Configuring the parallelism level
Measuring the performance on the JVM
Caveats of parallel collections
Non-parallelizable collections
Non-parallelizable operations
Side effects in parallel operations
Nondeterministic parallel operations
Commutative and associative operators
Using parallel and concurrent collections together
Weakly consistent iterators
Implementing custom parallel collections
Splitters
Combiners
Alternative data-parallel frameworks
Collections hierarchy in ScalaBlitz
Summary
Exercises
6. Concurrent Programming with Reactive Extensions
Creating Observable objects
Observables and exceptions
The Observable contract
Implementing custom Observable objects
Creating Observables from futures
Subscriptions
Composing Observable objects
Nested observables
Failure handling in observables
Rx schedulers
Using custom schedulers for UI applications
Subjects and top-down reactive programming
Summary
Exercises
7. Software Transactional Memory
The trouble with atomic variables
Using Software Transactional Memory
Transactional references
Using the atomic statement
Composing transactions
The interaction between transactions and side effects
Single-operation transactions
Nesting transactions
Transactions and exceptions
Retrying transactions
Retrying with timeouts
Transactional collections
Transaction-local variables
Transactional arrays
Transactional maps
Summary
Exercises
8. Actors
Working with actors
Creating actor systems and actors
Managing unhandled messages
Actor behavior and state
Akka actor hierarchy
Identifying actors
The actor life cycle
Communication between actors
The ask pattern
The forward pattern
Stopping actors
Actor supervision
Remote actors
Summary
Exercises
9. Concurrency in Practice
Choosing the right tools for the job
Putting it all together – a remote file browser
Modeling the filesystem
The server interface
Client navigation API
The client user interface
Implementing the client logic
Improving the remote file browser
Debugging concurrent programs
Deadlocks and lack of progress
Debugging incorrect program outputs
Performance debugging
Summary
Exercises
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜