TIL (Today I Learned) - Programmatic programming #6
Today's 3 Line Summary
- Concurrency is a requirement in our system
- Try to use transaction,semaphores for concurrency issue
- Consider to use Actor for concurrency without shared state
TIL (Today I Learned) date
2022.03.30
The scope I read today
Chapter 6 Concurrency
What you want to remember in the book
Topic 33. Breaking Temporal Coupling
- Activity diagrams show the potential areas of concurrency, but have nothing to say about whether these areas are worth exploiting.
- Remember the distinction: concurrency is a software mechanism, and parallelism is a hardware concern.
Topic 34. Shared State Is Incorrect State
- A semaphore is simply a thing that only one person can own at a time. You can create a semaphore and then use it to control access to some other resource.
- The current design is poor because it delegates responsibility for protecting access to the pie case to the people who use it. Let’s change it to centralize that control.
- This caused the build to fail, but in bizarre ways and random places.
- Most languages have library support for some kind of exclusive access to shared resources. They may call it mutexes (for mutual exclusion), monitors, or semaphores.
Topic 35. Actors and Processes
- An actor is an independent virtual processor with its own local (andprivate) state.
- A process is typically a more general-purpose virtual processor,often implemented by the operating system to facilitate concurrency.
- In the actor model, there’s no need to write any code to handle concurrency, as there is no shared state.
Topic 36. Blackboards
- This is a form of laissez faire concurrency.
- Order of data arrival is irrelevant: when a fact is posted it can trigger the appropriate rules.
- The actor and/or blackboard and/or microservice approach to architecture removes a whole class of potential concurrency problems from your applications. But that benefit comes at a cost. These approaches are harder to reason about, because a lot of the action is indirect.
How did you feel reading it today?
- In this chapter, it was easy to understand by examples.
- I learned about concurrency when learning about DB or threads, but I didn't care about it when writing code.Next time, I should try to consider concurrency.
- I learned about the actor for the first time.I should check more examples of use.