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
Mastering Functional Programming

You're reading from   Mastering Functional Programming Functional techniques for sequential and parallel programming with Scala

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781788620796
Length 380 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (23) Chapters Close

Title Page
Copyright and Credits
Dedication
Packt Upsell
Contributors
Preface
1. The Declarative Programming Style FREE CHAPTER 2. Functions and Lambdas 3. Functional Data Structures 4. The Problem of Side Effects 5. Effect Types - Abstracting Away Side Effects 6. Effect Types in Practice 7. The Idea of the Type Classes 8. Basic Type Classes and Their Usage 9. Libraries for Pure Functional Programming 10. Patterns of Advanced Functional Programming 11. Introduction to the Actor Model 12. The Actor Model in Practice 13. Use Case - A Parallel Web Crawler 1. Introduction to Scala 2. Assessments 3. Other Books You May Enjoy Index

Chapter 11


  1. Whenever a thread needs to access a non-thread-safe resource, it takes a monitor on this resource. Monitor guarantees that only the thread that owns this monitor can work with his resource.
  2. A Deadlock is a situation when two threads depend on the progress of one another, and neither of them can't progress until the other thread does. So both threads stagnate. See chapter 11 for an example of how a deadlock can occur.
  3. An actor is a concurrency primitive. It has a mailbox where it can accept messages from other actors. It can send messages to other actors. It is defined in terms of reactions to the messages of other actors. Only one message can be processed at a time by a given actor. It is guaranteed that if an actor owns a non-thread-safe resource, no other actor is allowed to own it.

 

  1. Since only one actor controls a non-thread safe resource, there is no danger of race conditions or deadlocks. Whenever other actors need access to the resource in question, they do so by asking the owner actor. The operation is performed indirectly by the owner actor of the resource, and the resource itself is never exposed to the outer world.
lock icon The rest of the chapter is locked
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 $15.99/month. Cancel anytime
Visually different images