Concurrency: how to shoot yourself in both feet. Simultaneously.
-
Upload
victor-haydin -
Category
Technology
-
view
393 -
download
1
Transcript of Concurrency: how to shoot yourself in both feet. Simultaneously.
Concurrency
How to shoot yourself in both feet.Simultaneously.
Victor HaydinR&D Manager @ ELEKS
The Problem
Multithreading?Parallelism?
Concurrency?
Single threaded programming
Concurrent programming*
* as you imagine it
Concurrent programm
ing** in real world
Shared state
Traditional way
WTF?!
Web 2.0 – 2003First dual-core CPU – 2005Cloud Computing - 2006
C++ - 1983Java - 1995C# - 2001
Alternate ways
Transactional memoryFunctional programming
Messaging
atomic {if (from.Ballance < amount)
throw new InsufficientBalanceException("Not enough money"); from.Debit(amount); to.Credit(amount);}
Atomic.Do(() => {if (from.Ballance < amount)
throw new InsufficientBalanceException("Not enough money"); from.Debit(amount); to.Credit(amount);});
STM HTM
Immutable data means no side effects. No side effects – no
concurrency problems!*
* except if you need I/O
Wait a second, what about I/O?
FP != easy concurrencyFP == easy parallelism
NActStact
Retlang
…or use single thread.
Q&A